Firstly, you need to build it’s confidence in such situations. One of the common this I see is that the owners tend to react before their dog does. This telegraphs a negative message to your dog and instantly puts it on alert.
To build confidence play plenty of puzzle, mental games with your dog (physical exercise is good but to build confidence your dog needs to get rewarded for making correct decisions and mental games are great for this).
Secondly, you need to keep your dog under threshold and build up slowly. This means when YOU see the other dog turn your focus on to your dog. As soon as you note that it has seen the other dog then calmly move away from it. Over time you can decrease the distance between you and the other dogs but initially you just want to keep a comfortable distance.
Once you get about 5 or 10 feet away from the other dog, with no adverse reaction from you dog, then try to walk parallel to it paying the other dog no heed and giving your dog lots of praise. You can gradually reduce the distance over time if your dog shows no signs of reaction.
Once you get almost side by side then walk together for a few seconds then calmly walk away and do something else. This is teaching your dog that other dogs are no issue and nothing to get fearful/excited about. This reduces the previous even to a non-event.
Once your dog shows more signs of confidence then you can extend the parallel walking further. From herein it is just practice, practice, practice.
Remember this is a marathon not a sprint therefore please go at your dog’s pace. Don’t worry about set back as they will happen. If they do just pare back to the distance that your dog was last comfortable with and rebuild.
If you know about he 5 Cs of dog communication the use this but, if not, just try to always remain calm and remove all emotion from your verbal interaction with your dog.