Finding the cross sectional shape of a rectangular prism through math is mega complicated and I would definitely not take that approach like I normally would want to

I would recommend using a whole screen viewport frame with an invisible background which is bound to the currentcamera with a transparent version of the target object put into the viewport frame to give this effect

With a part you can fetch the corners using just Part.CFrame and Part.Size, but with a model you could get the equivalent values with Model:GetBoundingBox() which also gives a box CFrame and size.

The corners can be fetched using the object’s right, up, and forward vectors that describe which direction right, up, and forward are relative to the object. An individual corner would look something like:

For corners on the left side you would use - on RightVector, and + for right side.
For corners on the bottom you would use - on UpVector and + for top side.
For corners on the back you would use - on LookVector and + for the front.

The easiest would be to compute all 8 corners and then convert them to screen space using Camera:WorldToScreenPoint(corner). Once you have each corner in screen space you can use math.min and math.max to compute the screen space bounding box. Compute the min on each axis to get the UI object position, and max - min for the size.

Edit: Lemme know if you have any questions about any parts of my explanation. It’s a little rough so I can clarify if anything is poorly worded.

Hm,
now that I think about it,
I could probably use my RNMU module to get the corners
( RNMU Inserter - Roblox if anyone is interested ),
then get the highest corner like I did for the 3d version but with the function.
Thanks.