Wouldn't a restaurant or fast food outlet let you use their bathroom? I think if you make it clear that your options are to take a dump either on their toilet or right where you're standing, they would show you the toilet immediately.
In my experience the east side of town, especially the financial district, businesses start being cagey about letting you use the bathroom.
Going westward, when you get to the Lower Haight or so, I can start naming many coffee shops with decent bathrooms and no lock on the door. And decent park bathrooms too.