Use some sort of market rate. If there's a lot of supply, but not a lot of demand at a given moment, the price drops.
That's pretty much what we have now in many areas of the US (not all). It is called Locational Marginal Pricing, or LMP. You can see various realtime pricing maps by searching Google for "LMP map". Here's one of them.
The problem is that the people advocating for "net metering", AKA "I want to sell my power at full retail rates", don't want to pay to keep the grid maintained. The LMP price is wholesale. Getting that power to where it is needed requires transmission lines, and transmission lines need maintenance and have a basically fixed capacity. Therefore, there are real costs involved in transporting electricity from where it is generated, to where it is needed. "Net metering" is a fancy way of saying that you don't want to pay those costs.
Generation costs (wholesale cost) + Grid transmission fees = retail price
You are more than welcome to run an extension cable to your neighbor, but if people want to sell to the grid, they need to accept that the grid costs money to maintain, and demanding that utilities pay retail rates for wholesale electricity isn't going to happen.