This glitch involves a Pokémon using Transform on a Pokémon with Rage, using Rage, getting hit with an attack so that the "[PKMN]'s rage is building!" message appears, then using a move other than Rage on the same or the next turn (or a battle item including X Attack and Guard Spec. (other battle items may work, but they haven't been tested) on the turn that 'rage is building!' appears).
This alters the Pokémon's moves to the moves it knew after using Transform, as seen on the 'check moves' screen, and after the conclusion of the battle.
At least for the user's transformed Pokémon, performing the steps of the glitch and then switching to another Pokémon or having the Pokémon faint will not ruin the glitch if the player runs from, catches, or defeats the enemy Pokémon.
Diamond, Pearl and Platinum steps
Prepare a Pokémon with Rage (and another move or a Guard Spec/X Attack) and a Pokémon with Transform in the first and second position of the party. Both should be able to take damage from Ty & Sue's level 19 (Diamond/Pearl) or level 23 (Platinum) Pokémon.
Example: Salamence and Ditto.
Battle Ty & Sue on Route 209, using the Vs. Seeker if necessary.
Have the Pokémon with Transform transform into the Pokémon with Rage.
Have the Pokémon under the transformation use Rage.
Have the other Pokémon use an attack on the Pokémon that just used Rage, to get the 'rage is building' message.
Have the Pokémon that got the 'rage is building' message use an attack other than Rage, or use a Guard Spec/X Attack.
Mimic Transform Rage glitch
This is an extension of the Rage glitch that lets you teach not just Ditto or Mew most moves (theoretically all moves except Chatter and Struggle can be taught via Smeargle) and Rage, but also any Pokémon that knows Mimic.
Put the Pokémon with Mimic and the Pokémon with Transform in the first two positions of the party. Either have the Pokémon knowing Transform be faster (by using X Speed(s) if necessary), or do this and go to step 3: on one turn have the Pokémon with Mimic use any move and the Pokémon with Mimic Transform into it, then on the next turn mimic Transform.
Have the Pokémon with Transform transform into the Pokémon with Mimic, then on the same turn Mimic it to get Transform.
Have the Pokémon that mimicked Transform use Transform into the other one of the user's Pokémon, then on the same turn switch that Pokémon into the Pokémon with Rage, which will have the moveset that you want.
Have the transformed Pokémon use Rage, then have it get hit so that the 'rage is building' message appears.
Have the transformed Pokémon use a move other than Rage, and the glitch should activate (you can go on to the 'check moves' screen to make sure).
HeartGold and SoulSilver steps (no double battle)
Via a wild Dunsparce
Wild Dunsparce from Dark Cave can be used for this glitch because they know Rage (and sometimes Defense Curl). Bring a Guard Spec or X Attack in case the Dunsparce is less than level 5. It's recommended to bring a Pokémon knowing Rock Smash, because wild Dunsparce are otherwise rare unless they are in a swarm.
Save in the cave before the glitch in case something goes wrong.
Put the Pokémon with Transform in the first position. Encounter a wild Dunsparce. If using Rock Smash, save before smashing the boulder in case you smash both of the nearest boulders and don't encounter a Dunsparce. If so, save, reset and try again.
Transform into the Dunsparce.
Use Rage against the Dunsparce.
Get hit by the enemy Dunsparce with Rage, to get the '[PKMN]'s rage is building' message.
Use Defense Curl or a battle item (Guard Spec and X Attack only tested), then the glitch should activate.
The Ditto should know Rage or Rage and Defense Curl according to the 'check moves' screen and at the conclusion of the battle.