I was wondering what the answer would be, because it's a hard problem. There was only the half answer of "they have experience".
The best answer I heard is that only domain experts have a chance to recognize each other. Other than that you are left with secondary signals like other people paying them for their expertise.
What? It gives at least a partial answer in the first paragraph:
> An expert has a track record and has had to face the consequences of their work. Failing is part of what makes an expert: any expert should have stories about how things went wrong.
This might sound so obvious as to be a non-answer, but I think it's a good point. There are many "experts" who acquired degrees in, wrote papers on, and now teach others about their area of focus, but have at no point in that process had to, say, stake their employment on being correct about that area.
For example, professors of literature have all written thousands of pages of text about good novels, but there's little evidence that they can actually make good novels.
Writing novels and analyzing novels are completely orthogonal skills. I bet there are many great authors who would completely suck at explaining other authors' works (or even their own), comparing different works, or explaining how literary works fit into and interact with the rest of the culture.
Just like reading code and writing are different skills, I see some of my peers perform the second without ever learning the first (at least other's people's code but I'm following your analogy), with the trigger reflex of 1- rewrite everything always and then 2- tell other colleagues to stop rewriting dammit
At least in software craftsmanship, experts are best identified working with others. It appears to be an irreducible process that cannot be pantomimed with trivia-based interviews or formulaic problems. Acting in an arrogant fashion or looking smart has zero correlation with performance, but it can fool some people some of the time who lack subject matter expertise.