I avoid it but there are times I can't, like if I have pulled in close to an unfenced lawn on a pavement to let someone else past, that my dog is then close enough even on a short lead, to pee on the tufty bits at the edge, without ever actually stepping on someone elses property.
My solution for those moments is a squirty water bottle, the push up/down sports caps work well, just squoosh the pissy bit, dilutes and rinses off the piss. If anyone has a strop at me I can show them I've done that, and apologise (but if they really go off after that they will be told to get to fuck, berating someone for an accident they've tried to rectify is just shitty behaviour!)
It CAN mostly be avoided though if your dog is walking beside you on a loose lead and you're paying attention and engaging with them, you can cue them to hurry along a bit and take them to somewhere piss is more appropriate.
It is also easier if they're taught to piss on cue, and frequently taken to places they can do this - for males, pair a cue with leg cocking and try to get them to empty out before you get to such risky, tempting places. (They may well still lift a leg, but the tank is dry!)