The yellow stuff sounds like standard liquid dewormer (strongid), which makes sense if he's coming from a shelter environment, as he's probably got roundworms. Of course, you don't give dewormer on a daily basis, it's more of a bimonthly thing, so it might be for something else. I've never heard of neutered or spayed animals requiring oral medication after they were desexed. All my vet does for kittens is give them a fentanyl patch, but your mileage may vary.
If he's just doing this after he's given the syringe of medicine, he might just be choking on it when you're administering it. That would make him cough and gag and maybe even vomit. If that's the case, he'll be fine.
If he's coughing, gagging, or having tons of mucus hours or so after being given the medication, he might be sick. I'd be really worried if he was lethargic, not eating/drinking, had diarrhea (especially if it was an unusual colour, as gross as that is), or the coughing or vomiting persisted. If this isn't the case, he can probably wait to see a vet.
When the clinics are open, contact the veterinarian that gave him the medication and find out what it is and what it is for. It's pretty irresponsible for a shelter or clinic to send you home with a medication whose name you don't know, or what it's for and the possible side effects.