It's an invalid deduction and hence a fallacy in either context.
From the fact that someone is an expert does not follow that what they say is the truth. There are countless of examples of experts telling falsehoods, either deliberately (lies), due to external pressure (bribery, intimidation, etc.) or even by accident (genuinely held believes and hypotheses that turn out to be false).
So it does not follow that something is true just because an expert said it.
So to say that it is "valid" in the juridical context is a fallacy of equivocation. Because what "validity" refers to in the juridical context is different from what validity refers to in the logical context. So just because it's a lawful legal process does not mean that it's not still fallacious.
The overall problem is that much of our everyday lives (including the courts) is not happening in the realm of neat logical deduction but in the realms of the more fuzzy inductive reasoning. So rather then being able to deduce knowledge from facts, we mostly have to compile good assumptions from data.
Or in other words the realm of deduction deals with certainties, so any possible alternative to the proposed conclusion renders the argument defunct, because it's no longer certain. While in the real world there's not much that is ultimately certain, maybe nothing at all, so to show that there are circumstances under which the conclusion can be wrong isn't really this ultimate rebuttal it's more or less the intrinsic problem of any inductive argument.
Like if you are a bird watcher and have seen thousands of swans and all of them have been white and someone tells you about a swan that they have seen, what color do you think that swan has?
It's not certain that it is white, in fact there apparently are black swans in Australia, but given what you've compiled as data, it's still reasonable to assume it's white and not idk rainbow colored. Because unlike with rainbow colored swans, you've actually seen white swans, so they do exist, you've seen plenty of them, so it's likely no a fluke and even if it's an anomaly it's one that seems to hold in your vicinity and you've only seen white swans, so there actually might be a reason or advantage to that, that actually links the color and the animal.
It's not NECESSARILY true, in fact it's false and we know that, but given what that person has access to, it's a reasonable assumption. It is not cogent but it's a strong inductive argument.
Or let's take driving a motorized vehicle. We generally consider it to be safe. Which is a fallacy. It factually is a safety hazard and in fact it is the cause of thousands (of direct) deaths each year. Yet what is considered "safe" is not a neat binary of "does harm people" or "doesn't harm people", but it's a matter of numbers and statistics and the question of what the general population, law makers and/or experts deem to be "still acceptable harm".
So not only could it be wrong to say driving is safe, in fact we KNOW that it is wrong to say that, yet we still are able to make an argument that it is "safe enough" with respect to a risk/reward calculation of allowing or banning it.
And similarly in the juridical context the question is not about the deductive certainty, but about the inductive beyond reasonable doubt.
If you were to investigate a case into the minutest of details you could NEVER come to a verdict because you could always hide a god in the gap that would explain the action without the defendants unlawful involvement or vice versa that make the defendant unlawfully responsible despite exonerating evidence. Like they could have hired someone through infinite+1 other people. Meaning no one could be charged or everyone could be detained indefinitely.
The other problem is that science itself isn't really a matter of certainty. Like if you're told the value of X is Y then it's not really Y but you should picture a Gaussian bell curve with Y as the center spot. So what science gives you is Y +- dY where in that range Y-dY to Y-dY about 68.2% of times the measurement is in that region https://en.wikipedia.org/wiki/Standard_deviation#/media/File:Standard_deviation_diagram.svg
That doesn't mean that it is not possible for measurements to be correct and outside of that interval it's just less likely. And at some point you draw the line between 0.000....0000....00001% being technically still possible and being so unlikely that it is treated as impossible.
Don't get me wrong it is still a fallacy to dismiss it, but in practical terms you are playing the odds either way and there are more likely than not more relevant factors to be considered.
Also another point with regards to appeal to authority. As SystemTheory has touched upon, the role of the expert might not be to serve as axiom giver, but as a source of information for the judge/Jury/lawyers etc. So in the end it's not the expert who crafts the verdict but the judge, so the primary role of the expert might just be to inform the judge and the judge likely does not need to take their word at face value but can ask them to explain it in layman's terms or to ask for a second opinion or whatnot. So just because they are an expert does not mean their evaluation has to be treated as fact.
Though again while it is not certain fact, there's a good chance that it has still better odds then the opposite of a layman's perspective or guessing at random. Also "expert" isn't a protected description so anybody from a senior professional, to a hobbyist, to someone having seen a youtube documentary can serve as experts, depending on the expertise of the other people in the room.
Another question is what they are actually talking about, like if the expert is just there to determine the guilt and shine a light on what is standard procedure in certain situations, then it might not even matter if what they say is THE TRUTH, it's fully sufficient if the defendant though this to be the likely cause or evaluated their situation in that matter, regardless of whether it actually had been that.
TL;DR it's still a fallacy and invalid in the sense of deductive reasoning, but courts don't play by these rules but rather by inductive reasoning
Edit: Also with regards to an argument from authority it's often useful to think of the use-mention distinction. So when researchers cite a study by someone else that is not always just to make them appear more credible because they link themselves to someone with authority, it might just be a reference to avoid having to reiterate points that someone else has already made. So mentioning someone is not always used to exploit their authority.