How does it do that? Mozilla spends a great deal of effort to make sure this type of fingerprinting isn’t possible.
indexedDB isn't implemented in Firefox's private mode. [0]
So if you can guess that it is Firefox, and can't use indexedDB, then you can guess that you're in private mode.
But there are other differences you can look for under Chrome, the simplest of which is that navigator.storage is smaller whilst incognito mode is active.
And under Safari you can just check if localStorage actually stores things.