As close as any episode of the live-action broadcast shows come is TNG’s Thine Own Self, where Picard’s only dialogue is one short line. Others have covered The Animated Series.
If you do not consider Mirror Universe doppelgängers impersonating the real captain to count, a large part of season 1 of Discovery qualifies. An interesting judgment call is “The War Without, the War Within.”
Captain Gabriel Lorca (who had secretly been an impersonator for the whole season) was dead, and for most of the episode, Admiral Amanda Cromwell is the commanding officer. In the final scene, she names Phillippa Georgiou the new captain of the Discovery. But, that is really her Mirror Universe counterpart, the Empress of the Terran Empire, in disguise. But but, Admiral Cromwell knew that when she put her in command.
In the Voyager episode “Living Witness,” Captain Janeway only appears as a hologram
Major spoiler: whose portrayal is not entirely accurate.
The Enterprise two-parter “In a Mirror, Darkly” might also qualify on technicalities, if you squint hard enough.
The Mirror-Universe version of Archer (a different person in a different universe) is the main character of these episodes, we also see Captain Forrest of the ISS Enterprise, and Archer does take over the ship and start calling himself “Captain Archer,” but this is a hoax and he is not the lawful Captain.
Another amusing possible technicality inspired by a comment is “Farewell,” the season 2 finale of Picard.
The new Borg Queen took La Sirena and flew off with it in the previous episode, so neither Jean-Luc Picard nor Cristóbal Rios is the commanding officer of any ship any longer. Nor does Jean-Luc Picard hold the rank of Captain. He is either an Admiral, a General, or an undocumented immigrant. When Q snaps his fingers again, most of the time-travelers reappear on the bridge of the USS Stargazer, but not its captain, Rios, who stays behind. Admiral Picard does not take over as commanding officer of the starship he is on, but picks someone else to.
Since I don’t see any mention of them yet, Lower Decks and Prodigy both have the (Acting) Captain appearing in every episode. Not every episode of Short Treks is set on a starship with a captain.