I don't speak for Riot, but I'm fairly certain they're stance is they don't want you to AFK regardless of what's going on.
The ability to mute people is there specifically so you don't have to endure someone who's flaming you / other teammates (or maybe they're just not pleasant to listen to In the first place).
You can still get a leaver buster penalty for leaving the game even if someone else does it first, which reinforces the fact that they really want you to stick it out (even if it sometimes feels really lousy). As FailedAbortion said, there's nothing stopping you from leaving, but you should expect leaverbuster to get you if you do.
Currently there's no "free pass" where Riot deems it acceptable / unpunishable to leave a game for any reason. Basically just mute if you're being harassed in chat, and attempt to surrender as soon as you're able to. There's really nothing more you can do beyond that unless you're willing to deal with leaver buster.