I've done this a few times. My experience (with US airlines most recently) is that you can only do it for "free" if you keep the stopover below 24 hours. Beyond that they start charging double or triple fares.
The other (hopefully obvious) requirement is that you need to pick a city that's a normal stopover on the route between your origin and destination otherwise, again, the fare will go up dramatically.
Most airlines have a "multi-leg trip" booking form that lets you book unusual journeys. Put in the flights separately - i.e. origin to stopover city, then stopover city to destination, and the same for the return flight(s).
You'll probably have to do a lot of experimenting with dates and times to find flights that work and also have reasonable fares.