I assume you want to store the serial number inside the FPGA without making anything on each board unique (for example, not willing to do something like create a hard-wired serial number on FPGA device pins).
I knew of someone who stored something similar to a serial number using the ECO flow documented in the Quartus handbook. A script was used to do the ECO steps to change a number in the FPGA. (I don't remember how the number was stored in the FPGA. It might have been hard-coded registers set up not to synthesize away.) The ECO script allowed making this change and creating a new programming file with the new number without doing a full compilation. Only the number got changed, so every board with a different number had exactly the same place and route in the FPGA for everything else.
That was before incremental compilation. Another option might be to create a tiny design partition to store the serial number and have everything else (the Top partition and any other partitions you create for their own purposes) set to preserve placement and routing. You can change the serial number and do a regular recompile to get a new programming file. The place and route for everything else will be preserved.
If you have a Nios CPU in the FPGA and it can write to flash, you could store the serial number in the flash.
Someone else might have a simpler solution.