This question is about the legality of a possible defence tactic that might be used in a criminal trial. It is a variation on things you see in lawyer movies fairly commonly. Suppose that a criminal trial occurs, and the defendant is not already in custody when the matter is heard (e.g., it proceeds by summons, or else he was out on bail). There is a witness to the crime and it is expected that she will identify the defendant in court as the perpetrator of the crime.
Now, suppose that the defence lawyer has reason to believe that this witness is actually not able to genuinely identify the defendant (as distinct from someone who looks a bit like him), but expects that the witness wants to assist the prosecution, and so she will nevertheless confidently point to whoever is in the defendant's chair and say that she is certain he is the perpetrator. So the defence lawyer attends court with a person who looks like the defendant, but is not the defendant. The lawyer can prove that this pretend-defendant was nowhere near the crime (e.g., he was overseas at the time). He sits this pretend-defendant in the defendant's chair and proceeds with the matter roughly as normal (while taking any necessary instructions from the actual defendant remotely by some surreptitious means). He is careful not to explicitly say that this is the defendant, but he acts in a manner that ensures that the judge and prosecutor will assume that this is the defendant.
Suppose now that the prosecution witness testifies, and as expected, she identifies this pretend-defendant as the perpetrator of the crime, and says that she saw him clearly, and she is absolutely certain it is him. The defence lawyer keeps questioning this, but she is resolute. At this point the lawyer reveals the charade, thus destroying the testimony of the witness and exposing her as either dishonest, or at least unreliable. He brings in the real defendant for the remainder of the proceedings.
Now, obviously this is a matter where the defence lawyer has perpetrated a ruse on the court, and has thereby misled the court, albeit temporarily. However, this is done in the pursuit of a legitimate purpose --- namely, to test the evidence of a prosecution witness and expose the unreliability of that witness. Also, to be clear, the defence lawyer will reveal the true defendant at this point in the trial regardless of the witness's testimony. If challenged on this, the lawyer could potentially argue that this kind of temporary ruse does not really constitute "misleading the court", since he will ultimately reveal the true defendant, though that might be a weak argument, since there is certainly a temporary misleading occurring in the ruse.
My questions: Firstly, is there any practical impediment that would make it impossible to implement this tactic? Assuming it is possible, what (if any) legal impediments would there be to using this tactic in a criminal matter? In particular, would the defence lawyer (and possibly also the defendant) be exposed to legal danger for misleading the court? Is there any case law where something like this has occurred (i.e., lawyer misleading court temporarily in order to test evidence of opponent)?
Note: I have not specified a jurisdiction for this question, but I am interested in the answer in any Western jurisdiction. If the answers depends on jurisdiction, then it would be interesting to know whether this is something that would generally be prohibited. I am aware that there is a large body of case law on the legality of ruses by police against suspects, but I am not aware of any case law on ruses against the court by a lawyer.
Update: For what it's worth, this exact tactic was just used by Saul Goodman in an episode of Better Call Saul. In that show, the actual defendent is seated in the gallery of the courtroom with the other spectators, and a similar-looking person is sat at the defendent's table. The result in the episode was a mistrial, and a dressing down to the lawyer from the judge, but no other sanction.