I have 2 males(9 and 8 months now) and my SOs brother has a male about 4 months older.
A few months ago(probably going back 3-4 months now) the SO's brother's dog was peeing on our dogs when they were together! And let me tell you, his dog is a 12 lb cock-a-poo and I have 2 doodles(they were probably about 40 and 60 lbs at this point).
It is definitely a male marking trait(the cock-a-poo marks everything, yet my 2 males have never marked 1 thing- so all dependent on the dog) and it doesn't seem to matter if it is a male or female they are marking, lol
Back on the leash is a good idea, or maybe take a spray bottle with you and if he goes to do it spray him? So he associated marking with a negative reaction.