In the Tanach, the word Yerushalayim is almost always written without a yud between the lamed and mem, but pronounced as if there is a patach under the lamed and a yud following it. We find though that Malki Tzedek was called Melech Shalem in Bereshis 14:18, and the midrash in Bereshis Rabba 56:10 implies that that is referring to Yerushalayim. This would seem to indicate that the city's name, at one point at least, was pronounced Yerushalem, as indeed it is vowelized in Aramaic, and that at a later period it was changed to Yerushalayim, as it indeed appears in Meggilas Esther. Did the switch occur, when, and why?
In the Chumash, we find "Malki-tzedek, king of Shalem", as well as Avraham referring to the place of Akeidat Yitzchak as "Hashem Yireh." The midrash says those names were combined, "Yireh+Shalem" -> "Yerushalayim."
Note that in Aramaic, it's pronounced "Yerushlame", which fits with how it's written Biblically -- no yud before the final mem. However in Hebrew, it's "Yerushalayim."
Which Tanakh are you referencing to find the correct pronunciation of Jerusalem (ירושלם)?
We find in the Dead Sea Scrolls fragment of [Ezra 6:2] : "Yerushalem" (ירושלם). - without any niqqud [https://www.deadseascrolls.org.il/explore-the-archive/image/B-367571].
- We also find Jerusalem pronounced "Yerushalaim" (ירוּשָׁלִַם) In the Tanakh [MT] published online @ [mechon-mamre.org]
- [2 Samuel 5:5] - "Yerushalaim" (ירוּשָׁלִַם).
- [Isaiah 2:3] - "Yerushalaim" (ירוּשָׁלִָם).
- [Ezra 1:2] - "Yerushalaim" (ירוּשָׁלִַם).
- We also find Jerusalem pronounced "Yerushalam" and "Yerushelem" in the Tanakh [MT] edited Rabbi A.J. Rosenberg [chabad.org] :
- [2 Samuel 5:5] - "Yerushalam" (ירוּשָׁלַ֣םִ).
- [Isaiah 2:3] - "Yerushalam" (ירֽוּשָׁלִָֽם).
- [Ezra 1:2] - "Yerushalam" (ירֽוּשָׁלִַ֖ם).
- [Ezra 6:3] - "Yerushelem" (ירֽוּשְׁלֶם֙).
- We also find Jerusalem pronounced "Yerushalaim" (ירוּשָׁלִַ֣ם) in Tanakh online @ [sefaria.org].
- [2 Samuel 5:5] - "Yerushalaim" (ירוּשָׁלִַ֣ם).
- [Isaiah 2:3] - "Yerushalaim" (ירוּשָׁלִָֽם).
- [Ezra 1:2] - "Yerushalaim" (ירוּשָׁלִַ֖ם).