I’m making a Tower Defense Game, using the URP.
To actually place towers, I shoot a Raycast from the Tower and use the hit position of the RaycastHit to place the tower, it actually works but I would like to find a solution to be able to place towers on almost plane surface:
If I have a mesh like a sphere, I would like the player to be able to place the tower on the top surface of the sphere where it’s almost flat, same for planes.

I came across an idea which is to calculate the DotProduct() of the hit.point + Vector3.up and the normalized Vector following the face of the hit.collider. It will return a float between 0 and 1 describing how big the angle is. I think i can exploit this result and use it with a given treshold to know if my surface is approximately flat.

How could I get the normalized vector that follows the surface hit by the Raycast (The blue vector represented on this drawing) to do this DotProduct calculation?

This will give you the surface normal, which is the vector that is perpendicular to the tangential plane of the surface at the hit point. For your example of a sphere, it would be the radial vector from the surface point. So if you dot product this and Vector3.up, you will get the angle off vertical that you are looking for.

Depending on your camera angle you may wish to add some checks to make sure the normal vector is positive in y to prevent the players clicking on any undercut faces.