Hello Sammy,
welcome to the board and thanks for posting.
Unfortunately, most of us here would need much more information to respond to your question with anything more than guessing and conjecture. That you can get at any water cooler.
First and foremost we’d need to know about you:
Are you young, old, short, tall, thin, heavy, male, female, fit, sedentary…
Then we’d need a better description of “locking”. Does that mean you are unable at all to turn the head left/right or forward/backward?
Generally speaking, the vertebrae in the spine can become mal-aligned. this is called subluxated. It is very common and happens to everyone many times throughout the day (and night). The spine is constantly adjusting itself in one way or another.
There is an appropriate alignment of the vertebrae and it is possible to hold that alignment for longer periods of time. However the spine is affected by our state of being - work, thoughts, emotions, diet, environment etc.
So the question “can yoga help” is depends on how we define “help” and to what degree we expect it.