get the real last block
Instead of getblockcount, you can call getblockchaininfo and read the headers field.

However, while this may give you a lot more blocks than the local block count, you will still only receive a count up to the point where your node has synced headers (which can be limited by time, network, how well synced your peers are)

There is no way to always get the latest block height reliably from an unsynced node.