Yes, if he is doing this constantly you need to take him to the vet immediatly. I would never give him cough medicine this could kill him. Yorkies are known to have problems with Collapsed Trachea or what's called Reverse Sneeze. But if they are doing it constantly the trachea may actually be collapsing. This is another reason why I never use a collar and
always use a harness. Please let us know how he is doing.
Take Care