As others have stated.. don’t yell. That only amplifies everything. Think of what that means to an already barking dog- you’re barking right back. Stay calm and be prepared to defend yourself if absolutely necessary.
Maybe it’s people that don’t spend time around dogs, but you can see it in their body language what their intent is. Hackles raised, head low, no excitability (the good kind) direct movement towards you.
I have a dog that is friendlier than shit, but will let out 3-10 barks when surprised on the trail, but does so while wagging his butt. Obviously I try and avoid him being surprised, but it happens. I’m surprised by the amount of people it scares. Their reaction either makes him nervous or shuts him up.
I get it’s stressful, but definitely just remaining calm and asking the owner to restrain their dog while having your hand at the ready would be my suggestion.