The short answer is it depends. Most states permit the use of electric scooters on public roads with bike lanes, but you should check with your local Department of Transportation as it can be city specific.
In states like California, the use of electric scooters is legal permitting a max speed of 15 mph. It's important to note that the Levy Electric Scooter is capable of speeds above this limit, so you should be careful to change driving modes when operating based on local laws. Shared scooters operated by companies like Bird, Lime Bike, etc automatically control the speed of their scooters to account for this.
Some cities have legislation pending to legalize the use of electric scooters, like NYC. In districts such as these the use of scooters isn't yet permitted, but often isn't strictly enforced. That being said, you should check the current state of regulations before purchasing to make sure you aren't putting yourself at risk to be ticketed. Update, Electric Scooters are now legal in NYC.
In general, operating on sidewalks is prohibited. For the safety of yourself and others around you, operating only in bike lanes or on public streets with a speed limit below 25 mph is recommended.