Assuming you're talking about a true public area, such as a park or sidewalk, the following analysis is valid. If its leased to a private entity or operated by a private company, they may have a greater ability to restrict your conduct.
As to this specific question about a public sidewalk, and this question only. When a fundamental consitutional right is at issue, in this case, the freedom of expression, a balancing test comes into play. Freedom of expression is an outgrowth of free speech.
The most likely interpretation is referred to as a strict scrutiny analysis. The law most be carefully tailored to address a legitimate state objective. In this case, that state objective is almost always soem type of police or security concern. The law at issue cannot be overbroad, so as to prohibit conduct which might otherwise be acceptable. Neither can it be vague, in that it might be susceptible to multiple interpretations.
It could also analyzed under a mid-level scrutiny analysis, which allows the government greater freedom in the breadth of the statute's reach.
The short answer to your question is, yes, they can create such a law. As to whether its lawful on a constitutional basis, that's a different story, which requires consideration of a lot of things.
Adding to this issue is the current political climate. Nutty laws like the Patriot Act, and ultra-conservative political appointees can skew constitutional law for years. It took 62 years for Brown vs. Board of Education to correct school segregation.
Eventually, the law corrects itself. And for our avocation, that's a good thing.
Ambient light is the best light.