Even if the smog technician completes your Mercury Topaz's smog check before it overheats, the fact that there is a headgasket leak, is enough to raise internal engine combustion temperatures high enough to produce excessive NO; which will cause your Mercury Topaz to fail the smog test.
You can always try and pass the smog check with the small head gasket leak, but we're fairly confident even the slightest head gasket leak is enough to disturb your Mercury's air/fuel mixture and cause high NOx emissions.
We recommend repairing the head gasket leak and having your Mercury Topaz smog checked after. If the leak is small enough there are fix-it solutions available from your local auto parts store which may be able to seal a small head gasket leak.