In A Brother's Price, the Whistler family are quite fond of this trope. If you are friends with them, you will never be alone. Eldest Whistler tells Jerin to hold his head high, and fear not, for he is a Whistler, and will always have the protection of his family. (As there are more than fifty of them, all trained gunwomen, this is not an empty promise.)
A big thing in Animorphs, but most obvious in #31, when Jake's father is at risk of being infested. Jake's panicking and on the verge of having a mental breakdown, and is expecting a longwinded lecture from Marco about the importance of staying clearheaded and rational, instead of doing something stupid and reckless. But Marco just says, "You're not alone, man."
Kurt Vonnegut in Timequake: Many people need desperately to receive this message: "I feel and think much as you do, care about many of the things you care about, although most people don't care about them. You are not alone."
The tribes of the Marat form bonds with totem animals, and this forms the basis of the tribes they divide into. Kitai, however, accidentally bonded with Tavi after he saved her life in the first book, and as the first Marat to bond with an Aleran, has no tribe to call her own and she tells Tavi that she is all alone in the world. You can guess his response.
This receives a callback a couple books later. Tavi's aunt Isana, speaking with Kitai, says it must be awful to be alone, without a tribe. Kitai's response is, "I would not know. I am not alone."
In the final book, after the Big BadVord Queen gives a powerful Breaking Speech to the entire nation by watersending, citing the true futility of their fight against her, how city after city falls and their once great legions all but shattered, Princeps Tavi sends his own counter-message, that the Legions are still strong. They will still defend people and protect the great nation of Alera. That the Big Bad will be routed and destroyed. And he is not without empathy for those trapped behind enemy lines and tells the commoners if it is to save their lives, they may accept the amnesty of the Vord Queen's offer to surrender to her. He will not punish them for this action.
In Dragon Bones, Oreg cheers up Ward at some points, but the most impressive one is the literal example: Ward and Tosten have been taken prisoners and sit in a small prison cell with mouldy straw on the ground. Ward tries to summon Oreg, half-convinced it won't work, but it does work. On which he first has to comfort Oreg, who suffered from the separation. Oreg then breaks them out. There is also one in the backstory; Tosten tried to commit suicide, but Ward found him in time and rode off with him in the middle of the night, to find him a place to stay, away from their abusive father. Came as a surprise to Tosten, as Ward had been Obfuscating Stupidity, and didn't seem able to understand his distress.
Jim Butcher also wrote a rather touching instance of this trope in the book Small Favor.The Archive, a twelve-year-old girl who is also the repository of all recorded human knowledge, has been kidnapped by Denarians who intend to torture her until she becomes one of them. Just before heading into a probably suicidal battle to save her, Harry sits down and writes: You are not alone... We're coming after you. Don't listen to them. Hang on... You are not alone. Post-rescue, the little girl cries in his arms and whispers, "I got your letter. Thank you."
Also, from a conversation between Harry and his father in ''Dead Beat:
Son. Everyone dies alone. That's what it is. It's a door. It's one person wide. When you go through it, you do it alone. But it doesn't mean you've got to be alone before you go through the door. And believe me, you aren't alone on the other side.
In general, Harry has to relearn every few books that he can rely on his friends rather than just take on the evil of the week alone.
Molly Carpenter, after Harry's death, pushes out on her own and asks none of her friends and comrades for help, resulting in her living alone on the streets. Karrin Murphy, Father Forthill and the Leanansidhe, Harry's amoral and twisted fairy godmother each try in their own way to help Molly realize she isn't alone and needs other people. Karrin offers a warm bed and some food. The good Father offers kindness and understanding. Lea likes to beat Molly in harsh training sessions and then summon Molly's enemies to potentially kill her if she fought them without anyone's help.
In Lee Lightner's Warhammer 40,000Space Wolf novel Sons of Fenris, Ragnar goes to eat in the great hall and finds Haegr, a fellow member of the Wolfblade eating alone, and Berek's company, to which he used to belong. But when he goes in, Berek's company recognizes and rises up to greet him and surround him with such enthusiasm that he is deeply touched.
In His Majesty's Dragon, Laurence forces Captain Rankin to go to his dragon Levitas as he lies dying. Rankin has been neglecting and verbally abusing Levitas throughout most of the book, so Levitas' final heartfelt "You came..." makes the scene even more of a tearjerker.
Laurence: "The government is not of my party, the King is ill and mad, but I have given my word!" Temeraire: "Then I must go alone... I will go alone...." Laurence: (after a very long pause) "No."
Gordon R. Dickson's short story "Steel Brother". A young man is alone running a robotic outpost in space to guard against the alien enemy. He can't face the fear until after he fails in battle and finally surrenders his mind to the computer memory banks where he discovers that the past (deceased) commander of the post left him a message, the same one every member of the corps leaves for his successor, "You are not alone, all along the frontier there is one of us standing guard, even if you die, another will take your place".
There are tons of examples in HP. Ron in the Shrieking Shack in Prisoner of Azkaban: "If you want to kill Harry, you'll have to kill us too!" Neville in the Ministry of Magic in Order of the Phoenix: "HE'S NOT ALONE! HE'S STILL GOT ME!" McGonagall during Dumbledore's arrest scene in the same: "He will not be single-handed!" Et cetera.
Which makes sense, since the series is about the Power of Love. In Deathly Hallows, virtually every character in the book alive and dead joins in to fight Voldemort's forces, all just so that Harry can be protected long enough to find the last Horcrux. Even before that, it's implied that the students of Hogwarts remain loyal to him and continue their own resistance, so that they'll be ready when Harry returns to help them.
Ron and Hermione assure Harry of this at the end of the sixth book. And at the start of the seventh, when Harry still doesn't get it Hermione gives him a fantastic speech that also serves as a What the Hell, Hero? for all the times he's considered going off without them.
And at the end of the seventh, as Harry heads off alone, he realizes he has the Resurrection Stone. He can't ask anyone living to come with him, but he brings back his parents, Sirius Black, and Remus Lupin, and they promise they will accompany him to the very end.
This is also the gist of Dumbledore's reassurance to Harry both in Chamber of Secrets and at the end of Deathly Hallows:
"Help will always be given at Hogwarts to those who ask for it."
The Heresy novels also provide a profoundly disturbing example of this trope. Early in The First Heretic, Argel Tal looked down on the Adeptus Custodes, who fought as individuals in contrast with Tal and his fellow Word Bearers. By the end of the book, Argel Tal's squadmates are either dead or twisted beyond recognition, any bonds of fellowship broken, and he muses that his brothers are dead... at which point Raum, the creature co-habitating his body, assures him "I am your brother."
Early in Heir to the Empire , Obi-Wan appears to Luke Skywalker in a dream. Luke tells him that it's been a long time, and Obi-Wan tells him that it's going to be a lot longer - he's here to say goodbye. He can't be Luke's Spirit Advisor anymore. When he vanishes, a despairing Luke thinks that that's it - he's alone. The last Jedi. The last thing Obi-Wan tells him is Not the last of the old, Luke. The first of the new.
At the end of Halo: Ghosts of Onyx, Kurt Ambrose is mortally wounded and barely able to stay conscious when the Elite commander approaches the rapidly closing portal that Kurt had stayed to defend. As he summons the will to stand, he sees a vision of all the previously fallen Spartans, both the Spartan-IIs that he had served beside and the Spartan-IIIs that he had trained. In unison, they silently give him the thumbs-up "can do" signal, and it steels his nerve for what he has to do.
In Jack Campbell's Relentless, when Geary faces returning to Alliance space a century since he left it, the sole survivor of that era, Desjani assures him he will not be alone.
In Juliet Marillier's Son of the Shadows, Bran is in a coma. Every man in his band tells a story of how he reached out his hand to them and gave them a place and an identity, to remind him that there are many people who love and need him.
The Lord of the Rings gives us the siege of Minas Tirith, where the defenders are trapped inside the city and outnumbered roughly 1,000 to 1. Very little help has come, and Rohan (their neighbors to the West) failed to answer their called for help. The dawn comes, and the defenders can only watch as the enemy breaches the city gates. Suddenly:
"In dark Mindolluin's sides they dimly echoed. Great horns of the North wildly blowing. Rohan had come at last."
In The Bible, following God is presented as rather impossible without divine intervention, so God is always sending a word of encouragement to those who choose to be on His side. Here's a few highlights:
To Joshua, as he's facing the prospect of filling Moses' very big shoes and leading the Israelites.
"As I was with Moses, so I will be with you; I will never leave you nor forsake you."
"Yet I reserve seven thousand in Israel—all whose knees have not bowed down to Baal and whose mouths have not kissed him."
And Jesus to His disciples, as He's about to ascend into heaven.
"...surely I am with you always, to the very end of the age."
The endings of both Brisingr and Inheritance from Inheritance Cycle feature Eragon lamenting his state of being alone and then being buoyed by the knowledge of the friends and family he has to help him and realizing that he is not alone.
A little spoiled by his self-imposed exile.
In the second book of the Croak trilogy, Lex comes back to town expecting her friends and dead sister to hate her. None of them do. Practically everyone else in the town does, but that's beside the point.
Happens pretty early on in The Zombie Knight. Shortly after becoming Garovel's servant, Hectorwho has been resurrected after killing himself out of loneliness is terrified at the thought of Garovel leaving.
Garovel: Don't you remember? When you talk to me in your head, I'll hear you no matter where I am. So don't frown like that. You understand? You're never alone, Hector. Not anymore.
"These books gave Matilda a hopeful and comforting message: You are not alone.”
In Starship Troopers the Mobile Infantry have an institutional loathing of leaving a comrade behind. Even in situations that are dire and require a retreat, the MI will go to great lengths to make sure that not even a single one of their soldiers gets left on the battlefield.
A variation on this is Barclay's justification for working with Bruce Maddox on an AI project in the Star Trek novel "Immortal Coil": if he and Maddox can create a Soong-type android, Data won't be alone any more.
In Jeramey Kraatz's The Cloak Society book Fall of Heroes, inverted. Amp objects to leaving his parents alone in the Gloom. Their response is that they are not alone, with the obvious implication that they have each other.
In Dora Wilk Series, when Bogna is close to mental breakdown because of her magic and her son is attacked by supernatural, Dora tells her this and promises to introduce her to other magicals and explain everything to her.