This solution has two aspects to it:
- Taking the photograph from the exact same location, perspective, angle.
- Overlaying the photograph in post on the reference image.
Taking the photograph
Using an overlay will help you find the right camera position and focal length to match the reference image. You don't mention which camera you will use for the photo, but I imagine every (modern) camera will have some way to show an overlay image while composing the photograph1.
In this previous answer I explained how to create a "ghost" image in Live View while composing an image using a Canon camera.
In this dpreview thread someone explains how to achieve something similar on the Nikon Z series, I've summarized the steps below (check the link for screenshots and a how-to video):
- First, take a RAW photo of the image you want to use.
- Then go into the Shooting -> Multiple Exposure menu:
- Set the mode to ON
- the number of shots to 2
- the "Keep all exposures" to ON
- "Overlay shooting to ON.
- Then select the custom image you shot as the first exposure.
- Now return to shooting by half-pressing the shutter and you'll see your selected grid image overlaid on your LV feed.
- When you take a photo the camera will generate two images - a multi-exposure that combines your custom image and the actual scene, and just the actual scene.
This camera has a "Sheer Overlay" function that seems to allow you to add an overlay to help compose the image. The manual describes it on page 354:
Use [Image Select] to select the pictures to be displayed.
Press [left][right] to select pictures and then press [menu] or the [shutter]
Overlaying the photograph on the reference image.
Photoshop provides an auto-align feature that can align multiple layers based on content. Full steps are included in the link, but I've included a summary below:
- Copy or place the images you want to align into the same document on separate layers.
- Select the layers you want to align.
- Choose Edit > Auto-Align Layers, and choose an alignment option.
1. Feel free to ask a new question specifically about displaying a "ghost" image with a camera of your brand if you can't find an existing question covering that subject.