They can indeed, especially if they’ve retained the ability to use Lick.
Of course, this is the least of your worries concerning gengar. They normally hunt by absorbing your life force through your shadow—which, incidentally, they can slip into without you noticing.
Needless to say, it’s highly recommended that you exercise extreme caution in areas where gastly and haunter are known to live. The reason why is because gengar are also likely living there; it’s simply that they’re less likely to be detected.
Happy travelings, anonymous!