If...your friend who is as your own soul, secretly entices you, saying, 'Let us go and serve other gods,' which you have not known, neither you nor your fathers...you shall not consent to him or listen to him, nor shall your eye pity him, nor shall you spare him or conceal him; but you shall surely kill him; your hand shall be first against him to put him to death, and afterward the hand of all the people.
I was going through a struggle in my faith to the point of considering suicide. My best friend asked me a series of impersonal questions to determine how serious I was about any self destructive behavior. His query grieved me; I thought he didn't care about my crisis except that I didn't hurt myself.
He did the right thing. His commitment was to doing what was right regardless of how I felt.
This is the closest example I can think of where righteousness has been exercised over the allegiance of a friendship. It is weak in comparison to having to kill one's own friend. It is discouraging to imagine putting my best friend to death—to tell everyone of his error and to throw the first stone. I think that after the loss of my friend it would cause me to attempt to draw close to God seeking comfort in knowing that He is righteous.
Eliminating sin from the population prevents the population's destruction. I can not think of any biblical examples where this law was carried out.