Question: I was walking back from shul with others on Shabbos and realised that there was some money in my coat pocket. What should I have done?
Answer: The Shulchan Aruch (OC 310:7) writes that if one left money on a bed, the bed becomes a bassis (base) and is itself muktze just like the money on it. The Mishna Berura (310:24) writes that as coins are muktze machmas gufo (inherently muktze) one wouldn’t be able to move them just because one needed the space. The same would apply to bank notes which are muktze machmas chesronam (valuables. See Shemiras Shabbos Kehilchas 20:20).
While money is muktze, clothing with money in the pocket does not necessarily become a bassis. R’ Yehoshua Neuwirth (Shemiras Shabbos Kehilchas 20:72) that providing one didn’t purposely leave the money in one’s pocket, the clothing would not be considered a bassis (See Shulchan Aruch OC 309:4). The Mishna Berura (310:31) writes that as people aren’t that bothered about a little bit of change that would not make the clothing muktze, either.
The Beis Yosef (OC 309:5) writes that only money in pockets that are fully attached would render the clothing muktze. If it was in a pocket that hangs, however, then it would not be muktze as the pocket is considered to be somewhat separate to the main clothing. One still shouldn’t wear it on Shabbos, however, as we are concerned that you may come to carry the contents outside of an eruv (See Rema OC 310:8; Magen Avraham OC 310:7).
R’ Neuwirth writes that if one was walking in the street when one realised that there was money they should ideally shake it out of their pocket (See Mishna Berura 310:29). If it will incur a real loss, however, or it is difficult to do so without removing the clothing or if one is embarrassed to empty it out in front of others, one may keep walking providing that they are in an eruv.
In conclusion, while the money is clearly muktze, your coat isn’t necessarily. While it would be ideal in such a scenario to empty the pocket out immediately, you can keep walking home if there was a significant amount, or if it would be difficult or embarrassing to do so in the street.