But when our hands are dirty/oily/wet I can’t get it out of pocket.
This is the typical XY problem. You do not need a hack to extract the soap, you need to make the soap available when you need it.
And one cannot usually get dirty / oily / wet unexpectedly. It means that you have a realistic chance to make the soap available when you are still clean enough, and then use it like a normal soap when you need it.
Example: you repair your car. Obviously, you will get dirty with oils and dust and whatnot. That is why you first make sure you have the cleaning agents readily available BEFORE the repair, as well as water and towels. Only after that you start the repair.
It happens to me that I take a bath, forgetting that I just put the towels into the washing machine. Should I ask what is the hack to get myself dry without waiting and without walking naked and wet through my apartment?
The same thing about using the restroom without checking the availability of toilette paper first.
Bottom line: Even if yo do not put the soap in the bathroom / washroom from the beginning (because other might use it), before getting dirty, at least remove it from your pockets, and remove it from its protective cover (box, bag, whatever...). Or at least open the protective cover, so you have easy access to it when needed.
EDIT: Another option (inspired by @WeatherVane 's comment)
Use a 2-step approach. Keep the soap in the pocket. Keep some other material (paper tissues, towels etc.) handy. Use the cheap material first, to remove the most of the oil / dirt. Now you can get the soap out of the pocket and use it for full cleaning.
EDIT: another option
Ask someone to give you their soap. When you are clean and dry (most likely, in less than 1-2 min), give them your soap.
NOTE: I do not know how many washes are in one soap. I assume that it is mostly a one-time use (maybe 2 or 3).