When doing a google search for public toilets in Rome, I stumbled upon this link https://pstop.it/p-stop/. You can add the app to your phone. They provide locations and photos of the P.STOPS and they also give listings of nearby attractions as well as helpful transportation (tram and metro stops/taxi stands) info. If you have the Roma Pass, the toilets are free.
I searched the forum and see that Markcw shared this link back in October. Thank you Mark! I am sharing again with a different title hoping it will be useful for travelers to Rome.
Or you could get a cappuccino at the nearest bar.