Merlin is one of the non-playable characters in LEGO Dimensions 2: The Rise of Enoch, from the Shrek franchise.
Shrek the Third
In Shrek the Third, after their ship crashes into sharp rocks, Shrek, Donkey, Puss and Artie get stranded on an island (possibly Lovers' Beach in Far Far Away). They meet Arthur's retired teacher Merlin, after Artie tries to separate himself from Shrek. Since Merlin retired because of a nervous breakdown (which he calls "third-level fatigue"), he seems rather eccentric, and his magic spells usually go wrong. At one point, when he prepares to teleport Shrek, Donkey, Puss and Artie to Far Far Away, he cracks his knuckles, only to fire a bolt that destroys a boulder.
In order to help Shrek and Arthur be reconciled, he makes them look into a thick cloud of smoke to reveal their thoughts. Shrek sees a baby carriage, but lies and says that he sees a "rainbow pony". Merlin is pleased and moves on to Arthur, who sees a bird and its father. The father bird abandons the chick, leaving it frightened and confused. Merlin is happy they decided to look into their soul, and as he retreats to his hut, Shrek takes the opportunity to show Arthur that they are not so different after all. They catch Merlin eavesdropping on their conversation when he plays the song "That's What Friends Are For" on a phonograph to add to the mood.
When Captain Hook and his cronies ambush Shrek, Donkey, Puss and Artie, he plays his piano, and Merlin is beside him playing it too until he is pushed away. After the villains retreat, Artie convinces Merlin to use a spell to teleport them to Far Far Away. But the spell causes Donkey and Puss to switch bodies (probably because they took each other's "hands" seconds before). After Prince Charming's defeat, Merlin returns, and Puss and Donkey force him to put them back in their own bodies. The spell works, but causes their tails to switch. Merlin thinks about telling them, but decides not to, though their tails have inexplicably returned to normal later.