There is a set of very old urban legends - fictional stories that are widely believed and passed around as true - which are closely related to this story.
In the book The Lore of Scotland: A Guide to Scottish Legends (page 291), one variant is presented:
In 1824, an account appeared in print of Aberdeen students ganging up on an unpopular sacrist (a term used at Aberdeen University for a porter). The man, named as Downie, was subjected first to a mock trial in a black-draped room and then to an `execution'. The strokes of the axe were simulated by flicking his neck with a wet towel, so convincingly that the man died of shock, and the body had to be secretly buried.
Snopes points to a number of other more contemporary variants:
We’ve been hearing versions of this story for years, tales in which the details change but the theme remains that of an unfortunate man who dies after he is trapped in a situation which he presumes to be dangerous but is later revealed not to have posed any real threat to his well-being: The air-tight room he’s locked in turns out to have a vent to the outside which brings a steady supply of fresh air but the man suffocates because he believes he’s used up all the oxygen; the cooling unit on the refrigerated boxcar he’s trapped in isn’t turned on, but the man stuck inside the car slowly succumbs to hypothermia nonetheless.
[...]
Could someone really think himself to death? The jury may still be out on that concept, but we’ve yet to find any documentation for the claim that someone once died because his power of thought turned him into a corpsicle.
The executed prisoner story fits the format very well. Alas, this doesn't prove it never happened, but combined with the lack of traceable details (who, when and where?), and the inconsistencies between the stories, it seems fairly safe to dismiss these as modern folklore.