In this guide, you will find how to pick locks with the lockpick in Hogwarts Legacy.
You will need to use the left stick to push the green light into a socket and then spin it around until the two corks in the bottom right spin. Do the same thing with the middle one; just throw them into a spot and then keep spinning it until they start spinning.
Put in the green one, then spin it around, and the cogs at the bottom will start spinning. Now you have to stop and hold it, and then do the same thing for the red one. When the two middle cogs start spinning, and if you leave that, it will unlock.