
A pop up umbrella can work really well, both as an initial deterrant but also as a visual barrier to put in front of your dog. If your dog is out of view, a lot of dogs will stop approaching.
You can also teach your dog to stay behind it.
With that and also with any sprays, compressed air etc, it's always a good plan to accustom your dog to it (the sound of it, I don't mean actually spraying your dog!) before you start taking it out, so they aren't upset by it should it need to be used.