When there's no toilet paper in a public bathroom you can try checking the other stalls for toilet paper or if someone is in another stall next to you, you can ask them for some toilet paper and they can hand it to you under the stall.
I had this happen to me before and thankfully someone else came into the stall next to me and I asked them if they could hand me some toilet paper and they did under the stall.
If there's no toilet paper nearby you can pull your pants back up and then go get some paper towels and then return to the stall to clean up and then throw the paper towels in the trash and wash your hands.
Before going into a toilet stall I make sure there's still some toilet paper or even at least grab some paper towels ahead of time just in case.
For example if I have to go really bad I grab some paper towels on my way into the toilet stall so I have something to wipe with in case there's no toilet paper.
If you're a woman you can keep a pack of baby wipes with you to wipe your bottom in case there's no toilet paper.
In severe enough cases you could remove your underwear if you really need to and then wipe with your underwear and then dispose of your underwear or use a sock if you have too and then dispose of the sock.
However I've mostly just pulled my pants back up and went to another stall to get some toilet paper or get some paper towels or asked someone for some toilet paper.