‘I don’t know why/how that hiker had the impertinence to think that I was talking to a tree.’
Both are possible
Your alternative would need ‘had got’ but the use of ‘got’ is not necessary, so in my opinion the sentence sounds much better without it, especially in the past tense.
Bearing in mind that Hyacinth has a colossal opinion of herself, I would suggest that ‘how’ is appropriate suggesting that she finds it impossible to imagine ‘how’ (in what possible way) anyone could have the impertinence to …