Is it possible to use a MacBook Pro as a second monitor for my iMac? Both of them have a Thunderbolt port.
If not, is there any other way?
You can not use your MacBook Pro as a second monitor for your iMac without additional software.
ScreenRecycler claims to allow you to expand your desktop across multiple computers.
As an alternative approach, Synergy (previously open source at synergy-foss.org) claims to lets you combine multiple computers into one. It will let you use both computers from a single keyboard and mouse.
For newer computers with Retina Displays and macOS 10.14+, the best way to use another Mac, iPad, AppleTV, etc. as a separate monitor is with AirPlay. See Mirror or extend your Mac display
Alternatively, (and separate from the original question) if you have an iPad Pro or an iPad Air, you can try using Sidecar
For modern Macbooks there's a feature called Universal Control which let's you connect to any other Macbook / Apple device and control it using a single mouse and keyboard, you just have to sign into both of them using your iCloud account.
Apple Target Display (Thunderbolt method)
Check this link before: https://support.apple.com/en-us/HT204592