You could have fought the search by alleging that it was an illegal search. A judge may have concluded after hearing from the police officer at a suppression hearing that he had no legal right to put his hand in your pocket to retrieve the money. It is very hard to justify a warrantless search of an individual unless the officer can articulate that he say contraband or his safety was compromised.
You could have "fought it". One can always do that. As you may have guessed, you could have also lost that "fight". I cannot give you an analysis on the probable out come without seeing the reports and interviewing witnesses. That said, it also appears that you made a decision to minimize your potential exposure. If you are dej, comply with the terms, stay clean for at least 18 mos and then you can apply to have the program terminated and your case dismissed.
In any search question, the analysis is: Was the search reasonable? You're asking about a Terry search (a.k.a. a frisk or "pat down" search). For a valid pat down search, first there needs to be a lawful detention. From there, the officer must have specific facts they can articulate that make them reasonably believe you're armed with a weapon or something that can be used as a weapon against them. It authorizes a patting or "grasping" search for weapons only. The entire case facts will matter in that analysis.
What they instead may try to rely on would be "plain view" - or in your case "plain feel". For a search to be valid, an officer must observe something with their senses from a place they have a lawful right to be. What justification would they try to claim for being in your pocket? I assume they would have said that they were just trying to safeguard your money during the investigation or something like that, leading them to put the money in your pocket and thus find the syringe.
Would you have been successful in suppressing the syringe? I don't know - and it's a done deal now anyway.