Its a simple process with two parts to it.
1. identifying the notes in the song.
2. playing the notes on the instrument of your choice, including your own voice.
The second part is all about knowing your instrument inside out - which key, which fret etc map to which note. The hard one is the first part. Loosely, the second is akin to coding and the first akin to developing the algorithm/design. The only way around it is to develop an ear(mind?) for the notes by abstracting songs - listen to a song as a sequence of notes rather than a "song". Its easier said than done.
For this task, learning theory is not useful. Surely, it can help identify the key with only a few notes which lets you fill out the rest of the notes, but, more often than not, real world songs, unless specifically designed to train students, don't follow the key bookishly and will always have an exception here and there, which means identifying the notes by the ear is still the key(ha!).