I frequently see people walking off of the sidewalk for a few seconds to maintain social distancing. They don't seem to have any issue doing this, as there is usually enough space between sidewalk and car lanes to not have to walk into traffic.
edit - If you need to take a walk through downtown Los Angeles or somewhere where it is physically impossible to social distance, then yes wear a mask.