If you're on the sidewalk, walk your bike.

If there are no pedestrians in sight, I might cheat, but the minute you see a pedestrian, dismount and walk.

I'm lucky that there are no bridges in my area that aren't safe to ride (even though I often see cyclists on the sidewalks ), but I'm aware that there definitely is such a thing. If you're in doubt, you might talk to some other cyclists.