Foolproof Accurate Way:
Find the nearest element (vertex, edge, or face). Compute distance to it. Check the angle-weighted psuedonormal to tell if inside or out.
given a point X inside a mesh
for every feature of mesh
compute closest point on feature y
compute angle-weighted normal at y.
project (y-x) onto the normal for sign
You can speed this up with a spatial accelerator (octrees, etc).
Why the angle-weighted pseudonormal? What is the angle-weighted pseudonormal? There's a whole proof for it: "Signed Distance Computation using the Angle
Weighted Pseudo-normal" by J. Bærentzen.
Forewarning, there are many approximations to it, as mentioned in the paper, one of the other approaches listed as an answer works for one triangle but suffers edge cases for many triangles.
There are many such libraries with the implementation if you don't want to write it yourself. VTK has this ImplicitPolyDataDistance. LibIGL as well LibIGLs. But there are many light-weight ones to do it as well.
Faster but often less accurate:
Scan conversion methods are also very popular and a number of methods fall under this category. Nvidia has a brief for it in GPU Gems here. Particularly outlining a method to do it fast on the GPU. A similar method exists for Euclidean distance transforms of a voxelized/binarized shape.
EDIT: Also worth mentioning narrow bands and hierarchical SDFs. Those are very popular as well. Instead of computing SDF values for every element. Say in an image. We can compute SDF values only near the boundary of the shape. With an octree you can compute it at each vertex and interpolate to get inbetween estimates. There are special methods for computing these as well and libraries such as OpenVDB.
sdf=udf-thickness. Ray marchers require signed distance functions. This distance function will work similarly to Blender's solidify modifier. The mesh will become like a thick shell, and the interior of the mesh will be airspace, just like the exterior. $\endgroup$