If you want to get all of the benefits of fasting, then you should only drink water. However, if your goal is only to lose weight, then drinking coffee while fasting will not impair your progress — it will probably make it easier for you to fast longer and eat fewer calories.
Fasting is broken when more than 50 calories is consumed. Make sure to drink coffee black if you are going to drink it.
For more on intermittent fasting and its benefits, click here.