Not all pepper sprays are created equal. Additionally, one needs to be aware of local laws concerning their use. Bear spray, which is a more concentrated form of pepper spay should be more effective, but when using any kind of spray, one must be aware of wind direction to avoid dosing yourself or an unintended person. Mace is superior (I once stopped a charging German Shepard dead in it's tracks - and it even remembered me and cowered away the next time it saw me.) but it's unavailable and/or illegal in most jurisdictions.Best course of action was leaving in the vehicle due to the danger posed by feral dogs. Pepper spray and treats aren’t always effective. Pack behavior makes feral dogs more dangerous than individual animals, even bears. Unattended, aggressive dogs in parks are unusual.
Firearms carry a much higher level of responsibility. If legal, in many states, it is not legal to shoot a dog unless you can prove it is endangering your life or that of another person. In some states, you can also use a firearm to prevent a dog from harming live stock, but in many states, that does not include protecting your own dog from an aggressive one. I do not recommend carrying a firearm unless you are well versed in the legal use AND have extensive knowledge of when and how to use it, including situational awareness of what lies beyond any intended target.