Rabbi Chaim Jachter in his book Gray Matter 2 (available on Sefaria) brings several different authorities, presenting several different opinions:
Serving as a Lawyer or Juror
Rav Ovadia Yosef (Teshuvot Yechaveh Daat 4:65) distinguishes between representing the plaintiff in Israeli civil court, which he prohibits, and representing the defendant, which he sometimes permits. Rav Ovadia argues that the plaintiff’s attorney actively endorses a non-Torah legal system by helping a Jew utilize it, in violation of Halachah, to collect money. The defendant, on the other hand, does not necessarily wish to appear in secular court. He might prefer to follow the Halachic requirement to submit the dispute to a beit din. Rav Ovadia thus permits representing a defendant who sought to have a beit din adjudicate his case, equating such a situation with “saving a victim from his robber.”
Rav Menashe Klein (Teshuvot Mishneh Halachot 4:213) prohibits serving on a jury, especially when the case includes a Jewish litigant, because performing jury duty glorifies a non-Torah legal system.
Rav Hershel Schachter told Rav Ezra Frazer that he strongly disagrees with this ruling. He explained that the Halachah requires non-Jews to establish a legal system, so a Jew does nothing wrong by participating as a juror in civil courts, unless both litigants are Jewish (in which case facilitating their trial supports a sin). Regarding capital trials, Rav Schachter argues that every government has the right to punish criminals within reason. For example, if a Jew murdered, a non-Jewish government may legitimately execute him. Accordingly, Jewish jurors may vote to convict a Jewish defendant if solid evidence convinces them that he committed murder. Rav Yitzchak Isaac Liebes (Teshuvot Beit Avi 2:144) also permits Jews to perform jury duty in both civil and capital cases.
An answer by Rabbi Daniel Kirsch on yeshiva.co expands on the reasoning of Rav Yitzchak Isaac Liebs (who Rabbi Jachter mentioned tangentially):
However, according to Rav Yitzchak Eizik Liebs (Beit Avi 2:144) it is permitted to take part in such a jury. He also holds that one can be a judge in a non-Jewish-- court not only to judge non-Jews-- but also to judge Jews.
His reasoning is that the non-Jews have to do seven mitzvot of Bnei Noach and one of the seven is to judge and undertake doing justice. These countries are permitted and even obligated to judge the way they developed their own justice system, and the way they feel is correct.
Another point that Rav Liebs mentions in permitting joining a jury is that the jury may not really be judging directly (this may vary from state to state). The jury may only decide with what level of crime the criminal is to be charged with, for example a misdemeanor vs. a felony and that is what they recommend to the judges who make the final decision. The jury doesn't have the last word in what the punishment will be; that is the domain of a professional judge. (it's possible that the Mishne Halachot and the Bait Avi are referring to legal systems that are not exactly the same, and possibly they got information about different states. In any case it doesn't seem that there is a difference in the ruling, and the Mishne Halachot would forbid it anyway and the Beit Avi would permit it anyway.)
In any case, as with most halachic questions when it comes to participating in the modern world, it looks like there are rulings to rely on in either direction. I'd advise asking your local rabbi about any specific concerns you have regarding participating in anything specific (provided you're allowed to disclose what type of trial it is, etc. etc.).