A Cognitive Shadow is the continuance of a person to act even after it has died; a spirit that has not yet moved on. It is a force of mind, holding one's spirit together, preventing it from diffusing.
"Cognitive shadows are basically ghosts, which can take a lot of different forms in the cosmere, but follow general rules."
Khriss declines to comment on whether the nature of a Cognitive Shadow is actually the soul of a person who died; she believes this to be a question for a theologian or philosopher.
She does, however, explain what is happening magically:
A spirit infused with extra Investiture will often imprint upon that very power. Much as the spren of Roshar become self-aware over time because of people's focus on the Surges as being alive, this excess Investiture can attain the ability to remain sapient after being separated from its Physical form.
On Threnody, the people think of these entities as ghosts, though really they are instantiations of self-aware (though, barely) Investiture.