It depends on how you hide your IP address. For the most part, most methods of hiding your IP address are legal — for example, using a proxy, connecting to public WiFi, or asking your ISP for a new IP address.
In some locations, using a VPN or the Tor browser could be restricted or even banned. Countries like China, Russia, and Iran heavily restrict VPN use, while the Tor browser is blocked in many locations (and using it can trigger surveillance due to its association with illegal activity).
In most countries, it’s perfectly legal to hide your IP address to protect your online privacy from hackers, advertisers, and other web trackers. However, you can’t hide your IP address to perform illegal activities, so make sure you’re aware of local laws and regulations in your country.