Say I wanted to created a cursed item that changes a player character from male to female or have the whole group wipe and instead of a reload, I raise the group as undead forms of themselves and they have to fight through purgatory to get back to their bodies and revive themselves.

Just some ideas I had and was wondering if the DM has the power to make something like this happen on the fly mid game?