Let's begin with something we know how to do. Given a point in 2D, one can project it to a segment by projecting the point onto the line containing the segment.
You do this by doing $s = (p - o)\cdot v$. where $p,o,v$ are the point, the origin of the line and the line direction with length equal to the segment. Doing this will produce the weighted signed distance of the projection onto the line. So then if you clamp that distance between 0 and 1. You know that $s * v + o$ is the shortest distance from the line to the point.
I am trying to do the same for a point projected onto a triangle in 3d.
After projecting the point onto the plane defined by the triangle, I want to clamp the barycentric coordinates such that the resulting barycentric coordinates match the projection. Or alternatively I want to project the point onto it's closest point on the triangle.