You may want to take a look at the Crypto Sign with Certificate page from the Apex Code Developer's Guide. That page shows the following example:
Blob data = Blob.valueOf('12345qwerty');
System.Crypto.signWithCertificate('RSA-SHA256', data, 'signingCert');
The difficulty might be with creating the
signingCert in your test class. From the above referenced page:
The Unique Name for a certificate stored in the
Salesforce organization’s Certificate and Key Management page to use
for signing. To access the Certificate and Key Management page from
Setup, click Security Controls | Certificate and Key Management.
It would appear the question would be whether you could simply assign a string as a the name of the certificate (I didn't try) or whether you'd need to find some way of accessing Certificate and Key Management from within a Test Class. I wasn't able to locate where certificates could be found in the Object Reference, but perhaps this will provide you with some kind of clue on how to locate what you need to accomplish creating one from within a test class.