I found a need for hactoolnet recently and struggled with the command line a bit until I got it, figure I post it here for future reference. A prior warning here, any modifications to the Nintendo Switch partition and any files within may result in data corruption, the worst case may be bricking the Switch. Now that we are aware of the risk, before attempting any of the steps below, make sure you have a good NAND backup as well as back up of the save files.
# 1. Read the save file from the User partition (e.g. User\save\000000000000000a). Note the CMAC Signature line is FAIL because we have not provided the proper key to verify its signature yet
hactoolnet.exe -t save 000000000000000a
# 2. Extract the save file with the proper key file (-t keys.txt). The key file essentially is a copy of the prod.keys and title.keys combined if you have backed it up with Lockpick_RCM
hactoolnet.exe -k keys.txt -t save --outdir output_folder 000000000000000a
# 3. Repack the extracted directory and sign it with the Switch's device key you like to transfer to. It needs an actual save file (e.g. 000000000000000a) to overwrite to, that's where it was confusing for me
hactoolnet.exe -k keys.txt --sign --repack .\output_folder -t save 000000000000000a
# 4. Verify if the repacked/signed save file with the same key as in the last step. It should have "CMAC Signature (GOOD)" instead of "CMAC Signature (FAIL)"
hactoolnet.exe -k keys.txt -t save 000000000000000a
Now we can put the save file (e.g. 000000000000000a) back to the User partition (e.g. User\save\000000000000000a) now. If we are putting in on a different Switch, just make sure to match the file name which you will overwrite.
Source
[1] Search in GBAtemp for "Edit OFW clean Switch save data from NAND backup/restoring via Fusee Gelee payloads", the author laid out a very detailed instruction and example for hactoolnet