Jujutsu supports change identifiers (change IDs) and uses them as quasi-anonymous refs. Git can support this too, perhaps most conveniently through message trailers.
It may make the most sense to use Jujutsu’s format, but UUID4 or UUID7 could also be helpful. Alternatively, the original commit hash for a change could be used.