|(image above from early Mead catalog)|
At the turn of the century, ammonia guns were popular dog deterrents. I have found a squirt with my waterbottle sufficient enough. Different times. Carrying a gun of any type might draw more attention from your fellow riders, not so much stray dogs.
I have never noticed another riding carrying a gun, maybe that’s what some riders carry in all their panniers.