Is this possible in C?
Depends totally on how "secure" you need it to be.
You have a licensefile containing a string of numbers, your program reads this number and also reads the serialnumber of the HAT.
Then you can xor the one number with the other and if the result is another secret number only you (the program) know about then you know that the license match this hardware.
Is this secure, no, because if someone have a lot of HATs with sequential serialnumbers you will see a clear pattern in the licensekeys.
How to fix ? Use encryption or hashing algorithms, they will generate numbers that are indistinguishable from random data.
Now totally secure ? No, but unless your users are experts that can de-compile or run your program trough a debugger its probably safe enough.