The most common reference to a spirit has always been the Vulcan katra, although it is sometimes interpreted as copy of someone's mind.
SAREK: Then you must know that you should have come with him to Vulcan.
KIRK: But ...why?
SAREK: Because he asked you to! He entrusted you with his very essence, with everything that was not of the body. He asked you to bring him to us ...and bring that which he gave you, his katra, his living spirit.
ー Star Trek III: The Search for Spock
TRESSA: The scrolls say we should be happy. That when we die the energy inside us is set free.
CORIN: Is it true? Is that what really happens?
TUVOK: Vulcans believe that a person's katra, what some might call a soul, continues to exist after the body dies.
ELANI: Do you believe that?
TUVOK: When I was younger, I accepted it without question. In recent years I have experienced doubts. I do believe there is more in each of us than science has yet explained.
ー Star Trek Voyager: "Innocence"
AREV: His body, yes, but his katra was spirited away before the last battle against those who marched beneath the Raptor's wings. Those who wanted to return to the savage ways.
ARCHER: What's a katra?
T'POL: Syrrannites claim it's the essence of a Vulcan mind. That it can be transferred from the body before death, then stored in some manner.
ー Enterprise: "The Forge"
If we interpret your question more broadly, there are several other instances where the supernatural or metaphysical is mentioned.
Original Series
In Who Mourns For Adonais?, the crew meet a powerful life form playing god. Kirk implies that humans believe in God.
APOLLO: But you're of the same nature. I could sweep you out of existence with a wave of my hand and bring you back again. I can give life or death. What else does mankind demand of its gods?
KIRK: Mankind has no need for gods. We find the one quite adequate.
Voyager
Chakotay believed in rituals to communicate with spirit guides.
(Chakotay lays out his medicine bundle on the floor of the shuttlecraft.)
CHAKOTAY: A-koo-chee-moya. I pray on this day of memories to speak to my father, the one whom the wind called Kolopak. Though I am far from his bones, perhaps there is a spirit in these unnamed skies who will find him and honour him with my song. A-koo-chee-moya.
ー Star Trek: Voyager: "Initiations"
In Barge of the Dead, B'Elana has a near death experience and questions whether there is an afterlife.
TORRES: Do you believe in an afterlife?
CHAKOTAY: I accept there are things in the universe than can't be scanned with a tricorder. What happened to you out there?
TORRES: I think I died. I died, and I was on the Barge of the Dead in the Klingon afterlife.
The Next Generation
In an early episode, "Where No One Has Gone Before", the Enterprise is thrown to the edge of the universe. There, thoughts take shape, and deceased individuals from their past appear. It's never really explained what's going on.
In "The Measure of a Man" there is some allusion to a metaphysical aspect, slightly more meaningful than a turn of phrase:
PHILLIPA: This case has dealt with metaphysics, with questions best left to saints and philosophers. ... Does Data have a soul? I don't know that he has. I don't know that I have. But I have got to give him the freedom to explore that question himself.
In Tapestry, Q claims that Picard has died and that Q is God.
Q: Welcome to the afterlife, Jean-Luc. You're dead.
PICARD: Q, what is going on?
Q: I told you. You're dead. This is the afterlife, and I'm God.
Despite Picard's opposition to the idea, Q's claims are never actually refuted.
Deep Space Nine
The Bajorans beliefs in Deep Space Nine, referenced in numerous episodes, might count. Early on it's made clear that their gods, the Prophets (and the Pah-Wraith), are just powerful aliens that live in the wormhole. However it's never explained where they originated from, and they apparently lived outside of normal space-time. (lending to their predictive abilities) Captain Sisko would eventually become a believer in the Prophets after experiencing their visions.
Still further, as mentioned in the comments, there have been numerous "energy beings" or individuals transformed to a "higher state of existence" throughout the series. Once in TNG Captain Picard temporarily became such a being11, and Dr. Crusher had sexual relations with a parasitic "ghost".12 However these are almost always presented as some kind of life form operating within the laws of physics, even if not completely understood.