There's nothing stopping you from charging money for FOSS software. Sell the first one for as much as it cost to write it.
Honestly, there's a real elegance to this model.
I'd argue the best possible model for goods that have no marginal costs (aka IP) is the "pay me to create it" model.
As in, let a creator decide how much they value creating the work. Then pay them that to create it - then release it free for everyone.
---
No ridiculous societal restraints that cost time and money to enforce (poorly) as IP law. Compensation is happening. Creating is encouraged.
Practical constraints make it unlikely we'll get much closer to this than Kickstarter (and equivalents) but it's a very honest model, that works with intellectual property by default.
There's nothing stopping you, true. But I think you will find that nobody is going to buy software for whatever thousands of dollars it took you to make it. So the limitation in this case is a practical one, not a legal or moral one.
I assume you mean "sell it before you open source it."
If you found one willing buyer while it was still closed source, odds are there are others. Why deprive yourself of additional income? Open sourcing does happen from closed source, but usually that's long after the income stream has exhausted itself (see, e.g., https://github.com/microsoft/ms-dos).