No, generally it is not illegal to use a dash cam in the US but there can be local state regulations that dictate how you can position the camera on your windshield. The main concern is that it does not distract you or obstruct your view while driving.
Depending on your state you should look up your local laws to ensure your chosen product and the way you’ve installed it meets regulation.
In the UK, you don’t need permission to install a dashcam, though there are separate laws that again dictate that nothing should obstruct your view. So far that has rarely extended to cameras. However, if you are involved in an incident the police may have the right to view any footage you’ve recorded as evidence.
These types of regulations are much the same in Europe and across the rest of the world, but you should always check your local laws before installing a dash cam just to be sure.
The only exception is if you are driving on private property rather than a public road, in which case you would need permission from the owner to film.