Good question!
I would just quote a fixed price to each prospect. Then they may come back with an hourly rate proposal….
But of course any company that sees your work as a part of their intellectual property will not be interested. So I could never do this if I was working on a product that the customer was going to sell.
Where I was able to charge a fixed price and own the IP was instrumentation software for Biotech companies. They were not interested in IP for obscure instruments. Also I found that small engineering companies who were struggling with their software capability would be very interested in a fixed price + royalty deal. Because they struggled to hire software talent.
So the key is to find customers with “non core” needs. Eg if they need a time tracking program they are unlikely to care who owns the IP. But if you are working on a search algorithm for a search engine company they will only employ you on a time and materials basis.