You can't dedicate a hand to holding other things while driving in the UK, whether that's eating, drinking, or smoking a cigarette.
It's not illegal, but if it's affecting your attention on driving, then you're driving without due care and attention, which is illegal.
And if you are so tired that you can't drive without constantly drinking coffee, then you are far too tired to drive, and it was highly irresponsible for you to drive in the first place.
The visiting friend should have ordered a taxi or taken a bus.