One possible scenario could be that Hermione is forced to betray Harry under the Imperius Curse. Maybe a powerful dark wizard manages to cast it on her without anyone realizing. Another could be that she betrays him out of a misinterpreted prophecy that she believes will save the wizarding world in the long run. For example, if she thinks handing Harry over to a certain group will prevent an even greater evil from emerging.
One possible scenario could be that Harry is tricked by a dark wizard into believing that his friends are in danger if he doesn't betray the rules of the Goblet of Fire. Maybe he's shown false visions of Ron and Hermione being tortured, and in his panic to save them, he does something that goes against the fair play of the tournament, like getting inside information about the tasks through improper means. Another could be that he's under the influence of a powerful potion or spell that makes him act against his normal values and betray the trust placed in him regarding the tournament.
Perhaps in a situation where a magical artifact is about to explode and destroy everything around it. Harry, being closer to it, decides to contain the blast instead of letting Hermione get hurt. His selfless act of heroism in this 'harry died for hermione fanfiction' is a way to show his deep bond with her, even if it means sacrificing his own life.
It could be when they find out some bad news about the war against Voldemort. Like if they learn of a major defeat of the Order of the Phoenix. Hermione, being highly empathetic and feeling the weight of the situation, breaks down on Harry's shoulder as he is the symbol of hope in their fight and she needs that connection to keep going.
In the fanfiction, perhaps Hermione first makes a list of all the characters in the Harry Potter universe who she thinks would be a good match for Harry. She then starts to subtly nudge them towards Harry. For example, she might invite Ginny, Luna, and Cho to a study group with Harry, and gradually, feelings start to develop among them. She could also be the one to smooth out any misunderstandings or rivalries that might occur between the girls vying for Harry's attention.
In some fanfictions, they could have a dance. Harry would be a bit clumsy at first, but Hermione would guide him. They'd laugh and twirl around the room. After that, they might sit on the balcony, looking at the moon and talking about their hopes for the future, like having a family one day or making the wizarding world an even better place.
Well, in this fanfiction, perhaps Harry and Hermione become really strict prefects. They could be known for always following the rules to the letter. This might make them a bit unpopular among some students at first. But as time goes on, they show that they are fair and only enforce the rules to keep everyone safe. Also, they might use their influence as prefects to get more resources for their studies and share them with their friends. Maybe they convince the teachers to open the library for longer hours or something like that.
Maybe Hermione has been too pushy with her academic knowledge in the fanfiction. Harry, who might be feeling stressed or frustrated, tells her off for not considering the emotional and practical aspects of a situation. He could say she's being too much of a know - it - all and not listening to others' ideas.
One possible scenario could be that in the fanfiction, Harry shows a deeper understanding of Hermione's goals and dreams. For example, he might support her in her academic pursuits more wholeheartedly than Ron. Maybe Harry is more involved in her fight for the rights of house - elves or other causes she cares about.
One possible scenario could be that Hermione is initially shocked. She might have been expecting someone else to ask her, like Viktor Krum. But then she realizes that Harry is being sincere. She could accept his invitation, and they start preparing for the ball together, sharing nervous laughs and excited chatter about what they'll wear.
One possible scenario could be that it's a moment of extreme stress and they find comfort in each other. Maybe they've just survived a close encounter with death eaters and the emotions are running high.