I had a hell of a time with this for a while with Logan. Even now he still tries to do it in pet stores and dog shows (where others have already marked). This past weekend, though, we were at a show for 4 days and he only marked once (WHILE HE WAS FREAKING LAYING DOWN! How can you pee while you're laying down?!).
Anyway, it took a lot of patience and consistency. He did mark in the house when he first came home, but that was fixed in a couple days with a squirt bottle. Elsewhere, it took not LETTING him mark and correcting HEAVILY when he did mark. At first I'd take him on walks in the same area, and always let him pee in the same place. He knew when we got to that place, it was time to pee, and he didn't have to pee elsewhere. Then stretching it out until we could go for a walk without peeing (I let him pee before we started, and again when we got to the car). At pet stores, I let him pee all he wants before we go in, and then pee again as soon as we come out. And watching VERY VERY CLOSELY while in the store. If he looks like he'll pee, get his attention and either get him moving quickly enough that he won't pee, or get him in a sit/down so he can't pee (well, usually can't pee). I did use a halti for this for a bit, but not very long.
Basically, give him designated times and places to mark, and forbid it everywhere else. You can't go to a pet store to shop and have it work. You have to go for the sole purpose of making sure he doesn't have an opportunity to mark. If you need to buy something, put him in the car and go back in for it. "Leave it" works well for Logan, but only after the marking got under control to begin with.
Barring that, a citronella or e-collar could work, depending on how stubborn your dog is. I never used the citronella collar for marking, just for barking, but I can see it working. I did carry a tiny squeeze bottle of water at times, though, and used it to squirt him if he marked. It didn't work as well outside as it did at home. You can also rub some Carmex on his nose to mask the smells of other dogs, and with the lessened need to mark, start reinforcing NOT MARKING.
It takes a LONG TIME. But it is possible to fix. Teaching potty on command helps, too. Gavroche will even fake-pee sometimes if he doesn't actually have to pee when I tell him to.