Yes, you can turn evil in Hogwarts Legacy if you unlock Avada Kedavra, the fatal and unforgivable curse. To do so, you will have to complete a few side quests for Sebastian Sallow, a Slytherin pupil.