The oldest example of something resembling a legal profession that I can place would be the sophists of Greece who were very prevalent in Socrate's time (late 400s BCE). These men were teachers who often specialized in teaching men how to defend themselves before courts and tribunals.
Taking Jesus Christ as the earliest example, the question becomes tricky. Certainly, Rome had a number of famous jurists such as Hortensius and Cicero. Additionally, in theory, an advocate could have been present. However, out in a province such as Judea, I do not know how prevalent lawyers actually were.
I can't speak much for the circumstances of the legal profession in the 17th century but I can talk about Galileo's trials.
If what you're asking is: "could Galileo have avoided being condemned while still carrying out his scientific work?" then the answer is yes, absolutely, because others did. Galileo was condemned twice, once in 1616 (where he was banned from teaching Copernicanism but otherwise given a slap on the wrist), and then again in 1633 (when he was placed under house arrest for the rest of his life). I'll focus on the first trial here. The second trial was a lot more cut and dry than the first because it essentially boiled down to the fact that Galileo called the Pope an idiot in print (which is basically true).
Without going into too many of the gory details, essentially Galileo's first condemnation boiled down to two things:
Alberto Martinez^1 argues that 1 was bad because it implied 2. In his 1610 book Sidereus Nuncius (Starry Messenger), Galileo describes the surface of the moon, talking about it having mountains, valleys, seas, etc. The problem with this kind of language is that it brings to mind the ideas of Giordano Bruno, who had been burned for heresy in 1600. Bruno argued that, if Copernicus is correct, then all the distant stars are suns just like our own, which means they have worlds. In the eyes of the Inquisiton, this means they have an Earth, which means they have humans, which means they have their own Jesus. In fact, because Bruno believed the universe was infinite, there should be infinitely many Jesuses. This position, that there were many worlds, hence Jesus was crucified more than once, had been repeatedly condemned by Popes dating back to antiquity, and Martinez argues that this was the reason Bruno was burned.
Galileo's language was dangerous because under traditional European philosophy, Earth was one of a kind. All heavenly bodies other than the Earth were perfect, and most importantly Earth was not considered a planet. So when Galileo starts describing the heavenly bodies as having the same kinds of characteristics as the Earth, and that the Earth goes around the Sun as a planet, he is entering a dangerous place theologically. It is not difficult to imagine that church censors, concerned with protecting the Church during a time it was under siege, could connect Galileo's language with Bruno's heresy. In fact it wasn't just the churchmen who connected the two; many commentators drew a direct connection between Galileo and Bruno.
This was enough to get Galileo into trouble. Back to your question though: could a sufficiently skilled tongue have saved Galileo? I can't speculate but I will say that the connection between Galileo and Bruno was tenuous. The fact that it took 6 years between the publication of Sidereus Nuncius and Galileo's prosecution shows that it took time for the Church to decide that Galileo's work was a serious problem (in fact they ball only really started rolling in 1615). Plenty of other people in Catholic countries publicly expressed support for Copernicanism (including Churchmen), but they were not prosecuted. Galileo could have avoided prosecution, but he simply didn't recognise the danger until too late.
Martinez, Alberto (University of Texas) The Heresies of Bruno and Galileo, History of Science Society Annual Meeting, November 19, 2015.
Galilei, Galileo. Sidereus Nuncius Raphael, Renée (trans). Isis, Vol. 101, No. 3 (September 2010), pp. 644-645.