Depends on what you mean by hack, and on the country. There are plenty of cameras that just have no authentication at all, so accessing them isn't really hacking, it's just regular browsing. This is how Insecam exists. If the webcam is private and you are using a vulnerability or even just a default password then it's likely to be illegal almost everywhere since that's an intrusion.
I vaguely remember some French law that said that it can be counted as illegal if you are accessing something that very clearly says it's private when you don't have the right to, so for example if you clicked a random link on a webpage and it took you to an unsecured camera, if you cannot deduce from the page that it is private then it's not your fault, if you can deduce that you shouldn't be here, it's okay as long as you press Back immediately, and if you continue then it's illegal.
Retrospring uses Markdown for formatting
*italic text* for italic text
**bold text** for bold text
[link](https://example.com) for link