The description of Transform is "User takes on the form and attacks of the opponent" and Sketch' s description is "Permanently copies the opponent's last move".
So, in a triple battle, if my pokémons are ditto (with transform), smeargle (with sketch and another move) and a random Pokemon and:
- Ditto uses transform in smeargle,
- In the next turn the random Pokemon attacks, and
- Ditto uses sketch in the random Pokemon
Would ditto learn that move permanently or Nintendo/Pokémon Company programed the game so that ditto wouldn't be able to use that move when the battle ends?