Vladimir Putin has signed legislation that bans people in Russia from officially or medically changing their gender.