You absolutely can keep him from peeing/pooping. Should you have to - well, that could be an entirely different debate.
Personally speaking, I am NOT interested in lugging home bags of poop and I know my dogs routines, so I put them out in the backyard to poop if it's their normal poop time, then walk.
Technically, here, the grassy area between the sidewalk and streets does belong to the city. But people maintain it like it's their own, so I would respect it as their own property unless you want bad neighbor relations (which you don't). So in this case, I would give the dog a little pop on the leash to keep moving while in front of that house, and continue on to the next one.
I have two males and both would mark regularly if given the opportunity, but don't mark unless I let them stop and sniff. I definitely don't let them pee on nice flowers, bushes, mailboxes, etc. I wouldn't have worried about a tree either, as in your case, but clearly the homeowner is concerned about the tree for whatever reason. So make your life and hers less stress free, and don't let your dog pee on her property.