It depends on what you do, but yes, it can cross into illegal territory.
Modifying a game you own for your own single-player use is generally a grey area rather than a crime. Distributing cracked executables, bypassing digital rights protection, or breaking into systems you do not own is a different matter, and those carry real legal exposure in most countries.
In multiplayer games there is a second consequence that arrives much faster than any lawsuit: anti-cheat systems detect tampering and issue permanent bans, often without appeal.
And practically speaking, most "hacks" distributed online are malware. The realistic outcome of downloading one is a compromised machine rather than an advantage in-game.