Here's a naive method of drawing a 2D box around a projected 3D mesh:
-Get the vertices of the mesh, transform them into 2D screen coordinates and find the min- and max-coordinates (this assumes the mesh only has one surface):
#Here mesh_inst is a MeshInstance and cam is the Camera node
var tf = mesh_inst.get_global_transform()
var mesh_tool = MeshDataTool.new()
mesh_tool.create_from_surface(mesh_inst.get_mesh(), 0)
var max_x = -9999
var min_x = 9999
var max_y = -9999
var min_y = 9999
for i in range(mesh_tool.get_vertex_count()):
var point_2d = cam.unproject_position(tf.xform(mesh_tool.get_vertex(i)))
max_x = max(point_2d.x, max_x)
min_x = min(point_2d.x, min_x)
max_y = max(point_2d.y, max_y)
min_y = min(point_2d.y, min_y)
-Draw the box according to the min- and max-coordinates.