According to what I have understood from reading multiple sites (I hope not wrongly), when 何ぞ has the meaning "something", it is read as なんぞ. In fact, from the few times I encountered this word, at least once, it had the furigana なん-ぞ.
However, my confusion comes when 何ぞ has the meaning "what" or the meaning "why", since I've seen/heard this word with the three readings なんぞ、なにぞ and なぞ, and I don't know if one of them is the most common one, so you may call it the standard one and generally read 何ぞ in that way, or if that depends more on the likings and preferences of each person.
On the one side, dictionary Goo says when 何ぞ has the meanings "what" or "why", it is read as なぞ as a result of a phonetic change from なにぞ.
https://dictionary.goo.ne.jp/word/%E4%BD%95%E3%81%9E_%28%E3%81%AA%E3%81%9E%29/
However, the same dictionary Goo also covers 何ぞ with those meanings under the reading なんぞ, apart from when it means "something" (何か).
https://dictionary.goo.ne.jp/word/%E4%BD%95%E3%81%9E_%28%E3%81%AA%E3%82%93%E3%81%9E%29/
So in the end, Goo dictionary says that 何ぞ with the meanings "what" or "why" can be read as なぞ (from なにぞ) and なんぞ.
On the other side, I've tried to see which reading Japanese people choose when reading 何ぞ with the meanings "what" or "why". For that, I went to immersionkit (I don't know what other resources could be useful too for this purpose) and I saw the next.
https://www.immersionkit.com/dictionary?keyword=%E3%80%8C%E4%BD%95%E3%81%9E%E3%80%8D
For 何ぞ with the meaning "why", apparently there are not examples available.
For 何ぞ with the meaning "what", there are the next ones.
どんな顔とは何ぞ - Here, 何ぞ is said as なんぞ.
闇より迫るものは何ぞ? - Here, 何ぞ is said as なにぞ.
So, to sum up, from my unlearned point of view, you can see no uniform criteria when reading 何ぞ with the meanings "what" or "why" and see 何ぞ said as なんぞ、なにぞ and なぞ.
Could you please enlighten me a bit with this matter? When 何ぞ has the meanings "what" or "why", which criteria, if any, should I follow when reading it (whether it be in a classic text or in more current ones) and expect when said by others?