That sounds like kennel cough. It is difficult to get rid of. Takes about two weeks with or without antibiotics. It can be contracted more than once, very contagious! When your dog seems better, wash all his stuff.
I have a Sheltie and we have been dealing with him coughing for about 6 months. He is 4 years old. He coughs then chokes and then sometimes spits up a small amount of what foam or flem. We took him for testing. He had a trachea wash. He was diagnosed with a form of Mrsa today. Because they could analyze the fluid they got from the wash they were able to find an antibiotic that will work. He has been on 3 other antibiotics that did nothing and had a chest x-ray. So our fingers are crossed.
MRSA is an infection such as staff. These usually come from cuts and scrapes and do not effect the lungs. The cough probably a virus