I am familiar with how Git creates SHA1 hashes for files (blobs), but not how they are created for tag objects. I assume they are, if I create an annotated tag, but what is
The content of a tag object is as follows:
object type commit tag tagger
Based on that text the SHA1 value is calculated.
how might I replicate it outside of Git (e.g., in Perl or Python)?
Take a look at libgit2 and its various bindings.