Back when I did quite a lot of that, I used this method.
- You need to find the available fares on the trip. I used Expertflyer, which required a paid subscription. There's probably a free alternative nowadays.
You enter a city pair, and you list the fares available. Each fare is associated with a class of travel, but also has lots of rules, including when they are valid, how long in advance you need to book, how long you must stay at the destination and/or if you need to stay over the week-end, and whether stopovers are allowed (and if so, how many, where, under what conditions, on what routing, etc.).
Note that usually the cheaper fares don't allow stopovers, though that may vary a lot from airline to airline. The most common rules are usually spelled out in fare lists, however you'll have to dig into the fare rules for stopovers.
The first letter of the fare tells you the fare class.
- Then, you look at availability on each segment for the various possible days. Again, I used Expertflyer for that back then. You can filter to include only the fare classes that you are interested in. Availability will usually be shown something like F4 J7 I4 Z2 Y9 R9 M4 etc. The letter is the fare class, and the digit is the number of available seats in that bucket (9 really means >=9).
Then it's a matter of finding a combination of flights on each segment, where each has availability on the fare class (bucket) you want.
Note that it becomes quickly quite complex if you mix different airlines, which you'll probably have to do if you want a stopover on the outbound flight but not the inbound. You're probably better off going through the same city (large hub for the airline of your choice) both ways. Possibly with a stopover one way and just a stop the other way. It may work out OK for airlines in the same alliance.
If you stop both ways (ideally with a stopover each time), you can try to assemble two round-trips, it may turn out to be cheaper.
Note also that stopovers imply additional costs: beyond the higher fare, there will usually be a bit more taxes.