Two distinct meanings, decided by context. (1) figurative: 'to pull dirty tricks behind the scenes' — common in
暗中做鬼 ('cheat in secret') or
做鬼脸 (pull a funny face). (2) literal: 'to become a ghost' — typically in melodramatic vows like
做鬼也不放过你 ('I'll come back as a ghost and won't let you off').