The question is if anyone has done what the people of hazrat Lut(a.s) did? Even had penetration and sodomy but now he is repenting before Allah, what if I apologize? Torment and punishment for him in the Hereafter (even he has repented), can he marry a woman? And if he gave up all his sins and tried to performall the obligations(wajibat), can he become a scholar if he wants to or not?

Yes if a person repents sincerely Allah will forgive. The best thing is to not talk about it and and bring it up and repent of that act. If a person repents, they can change their life.