i.e someone defending their best friend even if what they did was wrong. I suppose a bit like a defense lawyer in a professional setting.
This answer wont do, but it's close. According to The Random House College dictionary a myrmidon is "a person who executes without scruples his master's commands. The poster does not insist on someone's serving a master, but he does ask for the idea of blindly defending someone in the wrong.
- the use of clever but false arguments, especially with the intention of deceiving.
"trying to argue that I had benefited in any way from the disaster was pure sophistry"
- a fallacious argument.
"he went along with this sophistry, but his heart clearly wasn't in it"
How about advocate?
advocate: a person who puts a case on someone else's behalf
One can be an advocate for another even if one knows that the other is or may be in the wrong, as in your example of the defense lawyer.
Another possibility is the idiom have (got) someone's back.
have (got) someone's back: Be prepared to offer support or assistance to someone: ‘my parents always have my back’
More example sentences
‘I can trust that my wife will have my back.’
‘What she needs is to know that you've got her back if things get rough for her, that you're looking out for her best interest.’
‘I'm his friend and I've got his back.’
In many contexts, having someone's back means being behind them no matter what.
Let's consider apologist as in David Irving, the British revisionist "historian" and apologist for Hitler's Third Reich, who was branded a liar, Holocaust denier and falsifier of history by the presiding judge in his (Irving) failed High Court libel action against Professor Lipstadt and Penguin Books.
Apologist: A person who offers an argument in defence of something controversial. (Oxford Dictionary)
I would call such a person (a) partisan (the word can be both a noun and an adjective). From Merriam-Webster:
a firm adherent to a party, faction, cause, or person; especially : one exhibiting blind, prejudiced, and unreasoning allegiance
This term comes up a lot in discussions of politics (partisan politics is basically "my party, right or wrong"), but can refer to someone with an unreasoning allegiance to individuals as well as causes or political parties. For example:
Who could he talk to? . . . He thought of Rebecca and at once knew it was impossible. She was too partisan, too hostile. —Lillian Darcy, A Nurse in Crisis
[T]he book lacks definiteness and, more seriously, is marked by a sympathy that too frequently becomes outright partisan defense. —Book Review Digest, Volume 62, snippet view
Since you mention a word that would apply to an attorney, here's one more example:
This process does not assure that the adversarial system will be at play on appeal, because the appellate court will not be looking at the record with an adversary's eye for finding plausible claims, as is expected of a partisan defense lawyer. —Joshua Dressler & Alan C. Michaels. Understanding Criminal Procedure
Not a single word, but you can consider unquestioning defender.
Unquestioning obedience is total, and given without thinking, asking questions, or doubting. (Cambridge Dictionary)
And I would use the word as follows:
I don't want to be an unquestioning defender.