I had a lawyer once who did just that. A person he had been assigned to defend laughed while he told the lawyer how the elderly couple had begged for their lives but he killed them anyway. My lawyer somehow got the judge to let him out of defending the murderer.
A lawyer with a conscience...they do exist.
Can he tell the judge this information? I realize that there is attorney/client priveledge to protect you from self-incrimination,but if the perp CONFESSES that he did it why couldn't you reveal that? In fact wouldn't your friend be in trouble if he had the knowledge of guilt, but went into court and knowingly lied for his client?