Yes, you can.
First, when you're having a hacking cough, it means you're with an infection, the infection can make your voice sound hoarse.
Second, when you cough hard a lot, your vocal cord can be stressed, making the voice hoarse.
The first one, you'll need to get anti-infection treatment.
The second one, you will recover by rest and drinking water.