He might focus on his studies. In the wizarding world, there are so many interesting magical subjects like Potions, Transfiguration. By burying himself in books and learning new spells, he can at least distract himself from the lack of friends.
Perhaps he starts to explore the Hogwarts grounds more thoroughly. There are hidden passages and secrets all over the place. He could be spending his time finding these, and in the process, he might find some kind of connection to the school itself that makes up for not having friends. For example, he could discover an old room filled with ancient magic items and spend hours studying them.
Later, he could become depressed. Harry has always valued his friends highly, so losing them would be a huge blow. He might isolate himself in his dormitory, not participating in school activities as much. He would probably be constantly thinking about what went wrong and how to fix it.
Loneliness in Harry Potter fanfiction is often a central theme. It can be depicted through the inner thoughts of characters. For instance, Hermione might feel lonely when her friends don't understand her academic pursuits or when she faces prejudice for being a Muggle - born. Writers might show her sitting alone in the library, surrounded by books but still feeling isolated. Another way is by creating new situations where characters are separated from their loved ones and have to face challenges alone, highlighting their sense of loneliness.
Harry would probably be deeply hurt. He might pour himself into his studies or his work in the wizarding world. He could also try to distract himself by taking on more dangerous tasks or missions. But ultimately, he'd have to face his feelings towards Ginny and decide whether to forgive her or move on completely.
He might turn to his studies more intensively. Since he has no friends to distract him, he could pour all his energy into learning new spells and magic, becoming more powerful in the process.
He might go to Madam Pomfrey in the hospital wing. She has all kinds of potions and remedies to help with ailments, so she could easily give him something to soothe his stomach.
One way is by his body language. He could be described as always sitting alone in the common room, hunched over, not interacting with others. His eyes might be downcast, showing that he's lost in his own world of loneliness. Maybe he avoids eye contact, as if he's afraid of getting too close to people. The author could also use the setting to enhance this feeling. For instance, describing him walking alone in the empty corridors of Hogwarts at night, with only the sound of his own footsteps echoing, emphasizing his solitude.
He might be very sad at first. Harry has always valued his friends, so being forgotten by them would be a huge blow.
The demon could influence Harry by whispering dark thoughts in his mind. For instance, it might make him more cynical about the wizarding world and its values.
It could be that he is wrongly perceived as dangerous. After all, he has survived the Killing Curse as a baby and Voldemort is always after him. People might be afraid to get close to him for fear of getting caught up in the dark wizard's wrath.
One way is through education. Fans can start discussions about what is appropriate in fanfiction within the community. They can explain why sadistic content doesn't belong in the Harry Potter fan world. Also, moderators of fan groups and pages can be more vigilant in screening out such content when it is submitted.