The best position to sleep when you have a cough is to sleep with your head elevated by propping your head up on a pillow at least 4 to 5 inches.
When your head is elevated at least 4 to 5 inches gravity helps keep the mucus and post nasal drainage from getting into your throat and nose which helps stop the coughing.
I always sleep with my head elevated on a pillow when I have coughing and it does help a lot.
I would also recommend using a humidifier in your bedroom at night with some Vicks Vaporub as well to help get rid of the coughing.
Keeping moisture in your throat helps with the coughing and you can take a spoonful of honey at night before bed as well as during the day.
Drinking some warm tea with honey also helps lubricate your throat and moisturizes your throat as well and helps stop coughing at night and during the day.
I always keep a glass of water near my bed as well so if I do wake up coughing I can take a drink of water to help moisturize my throat and stay hydrated and then go back to sleep without getting out of bed.