Can TREZOR sign transaction with input address beyond gap limit? Suppose I use TREZOR with Electrum or Bitcoin Core HWI and significantly change the gap limit to, let's say, 100 000 addresses. I then receive BTC to my 999 999-th address and want to send them somewhere else. Will I be able to sign such transaction in TREZOR?

The question is, basically, does changing gap limit in Electrum or getting addresses beyond gap limit in Bitcoin Core HWI "getkeypool" generates extra private keys on TREZOR itself? And is such behaviour the same with all hardware wallets?
Yes, you can sign with that. Hardware wallets don't care about your gap limit, they aren't deriving individual keys when you setup the wallet. Rather they just store the master private key (or the seed used to derive the master private key) and then derive the individual keys needed on-the-fly. So if you tell it to sign with the 999,999th key, by giving it the correct derivation path, it will do so without complaint.