The Gospel of Luke tells us that Elizabeth didn't choose the name John herself. Instead, it was dictated by divine instruction. Here's the breakdown:
* Angel Gabriel's Visit to Zechariah: Before John was conceived, the angel Gabriel appeared to Elizabeth's husband, Zechariah (Luke 1:11-17). Gabriel announced that Elizabeth would have a son who would be named John. Gabriel said, "...you will have joy and gladness, and many will rejoice at his birth, for he will be great in the sight of the Lord... and he will be filled with the Holy Spirit, even from his mother's womb. He will turn many of the children of Israel to the Lord their God. And he will go before him in the spirit and power of Elijah, to turn the hearts of the fathers to the children, and the disobedient to the wisdom of the just, to make ready for the Lord a people prepared." Zechariah doubted the angel's words because of his and Elizabeth's old age, so he was struck mute until the child was born.
* Naming Ceremony: When it was time to name the baby, Elizabeth insisted on the name John (Luke 1:59-63). Her relatives and neighbors objected because no one in their family had ever been named John. They questioned Zechariah, who was still unable to speak, and he wrote on a tablet, "His name is John." At that moment, Zechariah's speech returned, and he praised God.
In summary, Elizabeth knew to name her son John because the angel Gabriel told her husband Zechariah before John's conception, and Zechariah confirmed the name in writing at the naming ceremony.