My 4yr old Shih Tzu keep trying to cough something up.
This is the 2nd day when he was just doing it, he vomit and and then started to shaking and gagging.
Hi
It sounds as though your dog may have swallowed something that has either lodged in his throat or damaged it.
Or it's possible that he is sick in some way and the coughing and choking is because his chest is congested, or he's having difficulty breathing.
Either way, the only thing to do here is to get him veterinary attention, and I'd recommend that you do that right away.
Only a hands-on exam can determine what is wrong, and only then can you get it fixed. Best of luck, hope he's doing much better soon.