Sirius could help Harry cope by sharing his own experiences of being an outcast in his family. He could tell Harry that just because his parents did this horrible thing, it doesn't mean he's unlovable. Sirius could also introduce Harry to his friends in the wizarding world, like Remus, who could also offer support and friendship.
After Sirius dies, Harry is in a really tough place. He feels like a part of his family has been ripped away. He may start to question his own actions that led to Sirius being in the Department of Mysteries in the first place. Harry will also feel a sense of loneliness, even with his friends around. But over time, he'll remember the lessons Sirius taught him, about being brave and standing up for what's right. This will give him the strength to move forward, and he'll use his memories of Sirius as a source of motivation in his fight against Voldemort.
Sirius often provides emotional support to Harry in fanfics. Since Harry has lost his parents, Sirius, being his godfather, fills that parental role to some extent. He might share stories about Harry's father, which gives Harry a sense of connection and pride. Also, Sirius's skills as a wizard, like his combat abilities, can be used to train Harry or defend him when he's in danger.
In some fanfictions, Harry becomes more determined to fight against Voldemort. He channels his grief into training harder and becoming a stronger wizard. He often has flashbacks of Sirius which fuel his anger towards the Death Eaters and Voldemort, seeing them as the root cause of his loss.
It's possible that in the cave, they start to see each other as equals rather than just a mentor - student relationship. They might argue about the best way to deal with the cave's mysteries at first, but through that process, they learn to value each other's perspectives. Also, if one of them gets injured in the cave, the care and concern shown by the other would enhance their relationship.
A plotline could be that Harry, after being dumped by his parents, has a very different personality. He's more withdrawn and distrustful. Sirius has to work hard to break through those walls. They could travel to different magical places to find a way to reverse what Harry's parents did or to find out the real reason behind it. Along the way, they meet other characters who either help or hinder their journey, and this all shapes their relationship and Harry's growth as a person.
Sometimes, Sirius's own secrets can harm Harry. In some fanfictions, if Sirius hides important information about Harry's family or his own past, and Harry discovers it later in a bad way, it causes emotional pain. A good example is 'The Hidden Truths' where Harry finds out Sirius knew something crucial all along.
It may explore the emotional bond between them. Sirius could be like a father figure to Harry. He gives Harry advice and guidance, which is different from what Harry gets from others. This special connection makes Harry trust Sirius more than anyone else.
Maybe Sirius gets help from some powerful wizards or witches who believe in his innocence. They might testify on his behalf in front of the wizarding authorities. Sirius also could show his strong emotional bond with Harry. He has always been there for Harry in spirit, and now he can be there physically to raise him, which convinces the authorities to give him custody.
Harry may also feel a sense of adventure. Despite the situation, he's used to facing strange and dangerous things. He might start to think about how he can use this situation to his advantage, like finding out more about his parents or the secrets of the wizarding world that Sirius might know. He could be a bit excited as well as scared. For example, he might be thinking that this could be a chance to get away from the Dursleys for good.
It could develop in a complex way. The spanking incident might initially create tension between them. Harry could be angry or resentful towards Sirius at first.