Or you could try simply supporting and defending the teammates so that they don't tilt. Having even one other person on the team speak up for them breaks the spell that the toxic player is weaving, so to speak, and gives them a chance to get back into the game. And you don't have to be toxic, or attack the toxic player to do it. It can be as simple as complimenting them on a good play they make, asking for their help with something, telling them your plan to help them. All of that disrupts the toxic rant, and it's ALL WITHIN THE SUMMONER'S CODE.
Let's say your midlaner is the 16-year-old-wanna-be-Faker, and he's railing against your adc for giving up first blood and being behind 20 cs. What do you do? How do you help them?
Step 1: Ignore the wanna-be. Tell your adc to just mute the guy, and then you don't respond to anything else that person has to say that is negative about the adc. Their negativity is not worth listening to. It's your call as to whether you want to mute the guy as well or not, but when you try to continually argue with what they say, all you do is give them attention that they don't deserve. Their words are toxic, detrimental and worthless. Their words literally are not worth the time it takes you to type a reply and hit enter. I'm sure you've been on the internet long enough to have heard the saying "Don't Feed The Trolls." It's the same way with toxics. If you don't respond to them, and never say anything back, they lose their power over the people they are berating. So all it takes is a single sentence to the adc. "Just mute him/her. Ignore his/her toxicity, and let's focus on winning this match."
Step 2: Find a way to involve the person being harassed:
As a jungler, tell them you will come gank, and if you get a kill bot or can run them out of lane, you will get their help with taking drag. Or, just look for a good time to ping their help at dragon, and then thank that player. Make a point of saying it. "Thanks adc-champ and support-champ. That dragon should help you with sustain/damage/etc."
As a top laner, offer to teleport gank for them. Ask them to ward the river or deep ward and let the enemy push up and tell them you can teleport in to get them back in the game. If you teleport in, and something comes of it, either a kill, or a turret, or even just burned summoners, tell them good job. If you don't have teleport, and you notice that the enemy jungler is spending a lot of time bot side, ask them to try and keep that jungler's attention, and get your own jungler to help you take rift herald. And then praise the bot lane for doing a good job of keeping the enemy team distracted. Even if they die, they still helped the team strategically and it gives you a chance to give that player a compliment.
As a support, if your adc is struggling, it can be rough, but you're in the best possible place to offer encouragement. You get to see literally everything your adc is doing, because you are always by their side in the beginning. So you see every good play they make. If they make a clutch flash, tell them. If they heal to save you from the enemy, thank them. If they play a trade really well, compliment it and encourage them. Tell them that if you guys can just do it one or two more times, then you've got an easy kill. Offer to help them last hit under turret if you need to. Guide them on the objectives they need to focus on, whether it's a dragon, a turret, a kill, or whether they just need to back, and when they make the right decisions with you, encourage them. "Awesome. we're catching up!" "She has a little more damage, but we have exhaust up and they don't, we can fight now if you come with me." "NICE! Good job bro!" If they make a mistake, you have the first view of it, and if YOU choose to say something like "whups! don't worry, we'll get them next time" "Oh man, that sucks. I miss that flash all the time too" "It's alright, we'll just play this one safe until you farm it up. You've got the late game!" the rest of the team will take their cue from you. This right here is actually one of the primary reasons why I main support. I enjoy offering support to the champions my champion plays with, but it goes beyond that. I support the players behind those champions.
Obviously, not all of those would work in every situation, but do you see the difference in doing any of those, versus attacking the toxic player? It's accomplishing what you want, the support and validation of a struggling teammate, without slipping into arguing or toxicity with the toxic player. But even beyond the fact that you are giving verbal encouragement, it gives you the chance to actually teach people metagame skills to combat toxicity-induced tilt. When you give someone something to focus on and small goals to work towards in a game, you make the situation manageable and you can help keep them from going into a multi-game long tilt streak.