As far as I know, it is not possible.
I can only imagine that you could check if the Path is empty and then use the Document Title to proof if it contains the default Template name prefix (something like "template*"), but of course you cannot be 100% sure that it is actually a template besides the prefix is dependent on the current Revit culture.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…