Back when I first heard Josh McDowell speak on the evidences for Christianity, he said that, of course, many people have died for a lie. What they don't do is die for something they know to be a lie.
Arguments from martyrdom are not designed to establish the truth of the claims in question. They are simply strong evidence that those who died sincerely believed in the propositions for which they were martyred. Yet, I keep hearing the skeptics argue that martyrdom doesn't prove the truth of anything, as if that was how Christians were arguing. This is a straw man. Martyrdom arguments are defeaters for deliberate fraud theories. The fact that the 9/11 hijackers flew planes into the towers doesn't prove that their peculiar version of Islam is true. What it does show is that they really believed that they would go to paradise if the died for Allah in this way.
Second, it's not the actual killing of the person that needs explaining. It's what I call martyrdom risk behavior. Here is a example of it, from Peter's speech outside the gate of Jerusalem:
Acts 2:36 "Therefore let all Israel be assured of this: God has made this Jesus, whom you crucified, both Lord and Christ."
In other words, Peter is telling people whom he believed had the power to engineer a crucifixion, that God had vindicated Jesus and made him Lord and Christ. So you've got a guy who, before the cock crowed, showed shall we say a pretty normal concern for his own life, now telling people whom he believes had gotten somebody crucified, that God had resurrected Jesus.
Now unless this part of the story is legend, it certainly needs explanation. Even if Peter wasn't martyred, he's setting himself up for it here.
I'm not sure Joseph Smith engaged in martyrdom risk behavior, although I am sure he knew that what he was doing was making enemies.
This wouldn't be an argument against hallucination theories. If Peter had had a believable hallucination of the risen Jesus, that would explain why he came to be firmly convinced of the resurrection.