If a doctor can be interviewed without being asked to operate on people, or an architect without being asked to build a home, can we not interview without asking someone to write code?
I'm not super familiar with doctors' career progression but as I understand they have a residency which is basically a super long training / interview. And I bet to become a surgeon at an elite institution you have spent a lot of time being watched doing your job.
Also another good example is cooks, who get hired based on working a shift unpaid to see how they fit with the team.
Moving to a doctor-style credential model would probably make the interview process less intense. But it also adds years of additional education and certifications. And it's unclear whether it would cause a net reduction of stress and pointless studying: pre-med and medical students aren't known for their laid back progression to gainful employment. A lot of the people here would clearly be shocked to discover just how adversarial jobs outside of software engineering can be.
Honestly I think this is a poor analogy. It's considerably easier to verify the work history of a surgeon or an architect. Their work is prominent and difficult to plagiarize.
Trades might be more applicable, and in trades you likewise have certain kinds of certification or even a guild-like system to keep skills and performance visible and consistent. There's not really any equivalent in programming (though there is in IT more broadly). Even a university degree is not really any particular proof of an ability to code, a lot of programs can be taken without having to write much code solo.
Programming is usually done collaboratively, either implicitly (through the use of base libraries) or explicitly (coworkers, group projects) and there are definitely people who freeride on those collaborations to a great extent.
Also another good example is cooks, who get hired based on working a shift unpaid to see how they fit with the team.
Asking for a hands on demo is pretty common.