You can 100% do this in many states. But solar, create your own energy and the state will force the electricity company to buy the excess capacity away from you.
I don't live in the states and it's not a regulatory but a technical problem, living in a rented flat that has hardly a good spot for a PV panel to hang to...