It is a myth. Dogs do not have the actual ability to lock their jaws so that they do not open.
However, the myth came about for a understandable origins, and that is because a dog's jaw strength is so powerful, that compared to a human's measly hands, it can feel like the dog has indeed locked its jaw. I once had to pry the jaws of a dog off of another dog's neck. And I mean literally pry, like stick something in the mouth, and pry, and even get my hands in there and physically open the mouth. This was on a small dog, and it took three people to get that dog's mouth open. A dog's jaw can have upwards of over a hundred pounds of strength in that little jaw, depending on the size of the dog, so that is why people say that dogs can *lock* their jaws. They can't actually lock it, but it can certainly feel that way to the human or the dog at the other end of the mouth!