How do I retain the state of the GameObject when I transition between scenes.

As stated in the title, let me give you guys an example. In Scene 1, I’ve already unlocked a door and my player has walked through a door that loads up Scene 2, however when my player goes through the same door again to go back to Scene 1, the door is locked again.
Does anyone know how I can go about this issue?

Use static variables, they persist their values between scenes.

Also, you could use the more advanced stuff, like Singleton pattern. You could put all the values inside it and they would persist.