At first I thought that you must hurt yourself in order to transform into a titan.
But later,
We see that Reiner and Bertholdt transformed without self harm, because they transformed immediately after Mikasa cut them in episode 6 of season 2 (episode 31 on Crunchyroll).
Also, thinking back, Eren did not commit self harm when he transformed from within the belly of the titan in season 1.
We see also that sometimes Eren is hurt and he still cannot transform, even though the injury was self induced. What exactly must take place in order to transform?