Camera projection transformation on a point

If I have a 3D point in the world (world space) and also a camera, how could I project that point into the perspective camera so that its position is screen-space?
I’m aware that it can be split into 2 steps (world to the camera’s space, then do the projection transformation) but I’m not sure how either could be coded or even if there’s a better alternative Blender has.

Another question, how could I do it for an orthographic camera as well?

Maybe this is what you are looking for?