Could I replace the antenna of a USB dongle with a RP-SMA connector?
Yes it would work. You would do it by desoldering or clipping the on board one and soldering on the new pigtail. That's it.

As others note, it may not work as well as the designed on. But it does work for many people. I've replaced a pcb trace antenna with a wired one with great results myself. Your mileage may vary, and be prepared to undo it or replace the device if you get bad results.