When you have a cold or cough it's best to sleep in an upright position with your head elevated 3 to 5 inches so that gravity can work to your advantage.
When you sleep with your head elevated during a cough or cold the mucus and other bad stuff will drain backwards and not into your throat which makes you cough.
So prop yourself up so that your head is around 3 to 5 inches and your coughing should lessen or go away.
I would also advise to use a humidifier in your room at night and take a spoonful of honey during the day or before bed.
Honey is a natural cough medicine that has been used for many years.
Taking a steamy shower and drinking hot tea with some honey can also help with the coughing.