I think imagination is the only way to answer this one, however my guess is they found a way to make him solid for a few seconds to swallow the potion. Better ask J.K Rowling! This is probably right-The mandrake potion may have been made extra strong and concentrated so the Nick could taste it. This strong potion may have been passed through him and that revived him from petrification.If you remember during the Deathday Party of Nick's the food was extra rotted and stale and spoilt so that the ghosts could taste it a bit by passing through it. Same may have been the case with the potion as I reasoned!!! (except one ghost remarked that he could 'almost' taste it.. in other words, he couldn't, but was reminded of what it tasted like in life)
I THINK THAT THEY MADE THE POTION REALLY STRONG AND THEN MADE HIM GO THROUGH IT/MADE IT GO THROUGH HIM AND I DON'T THINK HE TASTED ANYTHING I THINK HE JUST REGAINED CONSCIOUS OR MAYBE HE REGAINED CONSCIOUS JUST AFTER A FEW DAYS COS I MEAN HES A GHOST AND HES NOT REALLY UNCONSCIOUS (CAN GHOSTS BE UNCONSCIOUS?) THOUGH I AGREE YOU BETTER ASK J.K.ROWLING.
More likely, they cast spells on a sample of the potion to make it spectral, like him, so it could interact with him. Its likely there are ways to make inanimate objects spectral, so a ghost can interact with them, or else there would be no way for ghosts to send letters to one another, and no way Professor Binns could turn the pages of his notes.