Singularities for a class of non-convex sets and functions, and viscosity solutions of some Hamilton-Jacobi equations