There is no agreed upon etymology for either. For the Biblical Haman, the proposed Iranian etymology, for both Haman and his father (from haoma) sounds probable but it's just a speculation. For the Quranic one, if we reject the conflation of the two stories by Muhammad, we may be left with practically nothing.
Haman may be connected to Egyptian ḥ-m, “majesty”.
However, the Talmud says that “Haman was an object of idol worship, as he claimed to be a god” (Sanhedrin 61b). And Josephus states that “the foreigners and Persians worshipped him” (Antiquities of the Jews 11.6.5).
Ham/Hammu could refer to a solar deity (Egyptian Amun/Amun-Ra) and Haman to a priest or worshipper of Ham. Cf. biblical names like Hamutal (ḥam-tal), Hamiohel, Hamiadan and, of course, Hammurabi.
See also חַמּוּאֵ֥ל, Hamuel (1 Chronicles 4:26) and חמת, Hamat (< Hammat), “City of the Sun-God”(?) (Amos 6:2).
Hammurabi (Hammu-ra-pi) seems to have been an Amorite whose religion featured the Sun as an important deity (Marduk, Shamash).
Ḥam/ḥammu, related to the word for “hot”, could have been a name or epithet of the deity which occurs in a number of names in the region, such as, Ḥami’ohel (*“Ḥam (is) shelter”), Ḥami’adan (*“Ḥam is joy/gives abundantly”), Ḥamu’el (*“Ḥam is God”), etc.