Generally no — not if you are doing it for yourself and not selling the result.
The line that matters is commercial. Distributing or charging for modified code, or bundling someone else's assets into a paid product, is where copyright and licence terms bite. Most publishers also reserve the right to ban accounts that modify online games, regardless of intent, because a "bug fix" and a cheat can look identical from the server's side.
For single-player games with an active modding community, the publisher usually welcomes it. Check the EULA if you are unsure, and never assume that permission for a single-player mod extends to multiplayer.