Fermat wasn't so much a "lawyer" as a magistrat which means that he sat on successively higher levels of the Parlement of Toulouse, France. This period (17th century) was before the emergence of the doctrine of the separation of powers in Western thought, so that the Parlement was not a "Parliament" in the modern English sense of the word, but rather the judicial, legislative, and executive branches rolled into one.
Fermat was extremely active as a magistrat and penned numerous legal documents. In fact he was busy writing one only a few days before he died.
One of the most controversial cases Fermat was involved in concerned the trial of the priest Delpoy and his eventual execution. Fermat himself was unconvinced of Delpoy's guilt but was apparently overruled by his more powerful peers on the Parlement, including the president of the Parlement who is considered to have been rather hostile to Fermat. Fermat is said to have been in shock over the verdict and execution to such an extent that his productivity at the court declined sharply. He was similarly unable to work on mathematics for a period of a few months, as claimed by Digby.
More details on the background of Fermat's legal activity can be found in this 2018 publication in Foundations of Science where you will also find additional references on Fermat's activity at the Parlement.