One way to avoid history expansion is to quote `!` a backslash:
ls [\!a-g]est.txt
Of course when negating a set it is probably easier to just use `^` instead of `!`.
Another way is to temporarily disable history expansion by adding the character sequence `!"` anywhere (really!) before the (previously) first `!`. `!"` will be removed and any subsequent `!` have no special meaning.
!" ls [!a-g]est.txt
ls !" [!a-g]est.txt
ls [!"!a-g]est.txt
l!"s [!a-g]est.txt