I started with a 1:1 trainer who taught me to recognise some of the anxiety behaviours and the behaviours that he does to 'relieve' the anxiety. So when my dog sees another dog, he generally "clocks it" (i.e. looks at it) - if he's not going to react then he'll likely look away - reward this (i.e. treat or favourite toy, or do clicker training).
If he's feeling anxious about it, he might cock his leg after seeing the dog. Reward this if he looks away from the dog. He might 'shake it off' when the dog is gone (like he's shaking off water) - reward this.
If he's going to react, he'll keep staring. If the dog comes closer, depending on how he feels about the dog (black spaniel = enemy #1) he will react. I can generally judge if he's going to react from a distance and I will move away.
Don't punish 'bad' behaviour in the sense of scaring him, but I have found a firm 'no' can snap him out of it if he's reacting to a dog - if it's not a black spaniel 😅
The most effective thing is to just keep distance and reward as soon as your dog looks away from a dog, any dog, even those you know your dog wouldn't react to. Over time, you can maximise positive interactions with dogs you know they won't react to (so my dog LOVES small dogs for example, so we have very controlled fun interactions with small dogs we know and like). And always minimise any negative reactions, so walk away from any dog you think will cause a reaction, and reward when your dog drops their attention from that dog.
Of course minimising negative reactions with dogs is difficult when dogs run over without being recalled!
This has taken about a year of training to get to a half-decent point by the way (where he doesn't have to be muzzled). And you have bad days and good days. Remember a dog has such heightened senses that things you won't be noticing will make them more alert e.g. my dog is more reactive if smells are stronger in an area, when snow changes how things smell and sound etc. If he's achy after visiting the dog park (the secure, enclosed one you hire out before anyone tells me off haha). My trainer taught me that training is not linear - it goes all over the place but there is a net gain at the end. It's SLOW. But my boy is worth it ❤