field of view – Can a ratio/function be created to calculate focal length vs size-in-frame if I have two focal length shots from the same sensor and position?

I am trying to figure out what focal length lens I would need to get a specific object to completely fill the image from a camera. Assuming I have two RAW files from the same camera body, shot from the same position, is there a way to create a ratio or equation that would help map the necessary focal length to fill the frame with a given object, such that I could then say “that street light at 100mm is 50×50 pixels, so if I change to an 800mm lens, the ratio is y, so that object is now 200×200 pixels.”

Furthermore, once that ratio is calculated, will it always apply to all lenses on that body, or would the ratio change based on the lens? For instance, if I have a 70-200 zoom lens, would changing to a 100-500 yield the same equation or does individual lens optics play a part in the calculation?

I’m considering investing in a longer lens to try out wildlife/birding photography but I’m trying to wrap my head around “800mm would make distant-object-x ‘this big’ in the frame.” I’m trying to figure out whether mathematics can be used to help answer that question definitively.