Yes. A dog can approach a person and still feel pain or worry when a hand makes contact. Ask visitors and children not to pet them for now. Do not test different body parts to find a spot that does not hurt. Arrange a veterinary examination, especially if the yelping is new, getting worse or comes with changes in movement, appetite or sleep.
Give your dog a comfortable way to move away from people. If they keep soliciting attention, use a calm voice and let them choose company without touch until the vet advises otherwise. The petting-choice article explains how to read consent, but a yelp is a reason to check for pain, not only a communication lesson. Supervise children and use a secure barrier when they cannot reliably avoid touching.
After the vet has addressed any physical issue, a qualified reward-based professional can help if handling remains frightening. Do not punish a growl or snap if the dog needs more space. Tell the clinic exactly when the yelp occurs and how the dog behaves before and after.
Today, pause the petting and call the vet. Choosing to approach someone does not waive your dog's need for pain-free touch.
Sources: VCA on recognizing pain in dogs, Dogs Trust on handling and dog choice, Dogs Trust on child and dog safety.