So basically, you first have to make your map. Pretty simple. Once you do, open the wad in SRB2 with the "-warp (map number)" and "-metal" parameters. This should put you on the map, ready to record a Metal Sonic replay. Once you finish the level with this, the game will close with an error message which reads something along the lines of "Replay saved as MAP##MS.lmp". Open your map in a wad editor of your choice, and put the replay lump (found in the SRB2 directory) in the wad.
Now, before you go saying it works, you'll have to start the replay within the map. This can be achieved through the use of trigger linedefs. For example, Black Core Zone 1 uses a "
Level Load - Once" linedef in order to trigger the start of the race, using
linedef type 440 - Start Metal Sonic Race. To get a better understanding, please read the Wiki Page
here.