Adding a Serial Number to a PIC18
How can I have a Serial Number in a PIC18 device?
The "MPLAB® XC8 C Compiler User's Guide" explains how to place a serial number at a specific address in the program memory in section 4.8 "SERIAL: Store a Value at this Program Memory Address".
There is also a #pragma config available to place a value in User ID memory.