In the case of solar panels, I'm going to assume the OP is talking about something like a grid-scale solar farm instead of rooftop solar production:
1: You need an agreement with "the grid" to get payment for the electricity you generate.
2: Feeding electricity into a power grid is a very dangerous thing, at a minimum the grid operator needs to make sure you aren't going to cause a fire or otherwise break their equipment.
---
That being said: If you're a homeowner trying to set up a small solar installation, you can pair the panels with batteries and skip feeding into the grid.
Also in the UK it would probably be a civil lawsuit, which doesn't have a jury, although if you violate a civil court order you can still get a jail sentence.