I need help making a datapack for a minecraft challenge!

For more context, I am trying to make a datapack that will work with my minecraft challenge that i'm trying to do with friends. The main premise is that players are pitted against one another in trying to claim the Dragon Egg after the End Dragon is defeated. Whoever ends out on top is deemed winner, but I want there to be some stakes: I want a line of commands that will make players go into hardcore mode when two requirements are met: 1) When the End Dragon is killed 2) When a player enters the End. I'm not even sure if this is possible at all, and I figured this would make the challenge more fun, turning it into a sort of Battle Royale at the end.
Continue to help post