I've done it by putting the freehub body and some clean-ish mineral spirits into a canning jar, and then putting that and some soapy water into the ultrasonic cleaner. I'll "buzz" it a couple times, then take it out and spin it a couple times before putting it back in to "buzz" some more. I don't like the idea of putting water-based cleaners inside mechanical parts, because then you have to try to rinse and dry them completely before re-oiling. With the method I detailed above, once I'm confident that any grit and leftover lube has been shaken out, I can just leave it out overnight to dry and then flush it with oil.
Although, to be honest, if I know that the freehub has lived a clean life, or that I've done the mineral spirits cleaning before, I'll usually just flush with fresh oil (until clean oil starts appearing on the other end) for subsequent maintenance.