That is Shatner playing a deranged Captain Garth at the penal colony, where Garth is using his shape-shifter ability to look like Kirk and flipping out when Spock calls his bluff on asking for a chess move passcode as a way to transport back to the ship.
That’s Lord Garth.