In level 3 "Space suits you, Sir!" on the third space ship task Robin must use a VR game to find the three digit code. In the first maze part of the VR game there are three tiles Robin can stand on to light up. The third tile will reveal the Shazam character token which can then be picked up.
Shazam costs 250,000 studs in the character selector. Buy him then switch to his character. Hold Y to transform to Billy then hold Y to transform back to Shazam.