Both words have the same phoneme /æ/, but the vowel before /t/ (and any other "voiceless" consonant) will be slightly shortened (clipped) in native English speech. In NYC accent, /æ/ is usually /eᵊ/ or /ɛᵊ/ in one syllable words ending in /d/ (and some other sounds), but this is *not* the case with “had”, the sound change does not apply to past-tense verb forms, unstressed modal auxiliaries, and some function words. I can go into more detail if are you really interested.
Note that "hat" and "had" do not sound the same to any native English speakers, nor do they rhyme.