The task itself isn't complicated.
The input Dos executable needs to be prepared for PE header.
Thus the Dos header must be extended up to $40 bytes (the last four bytes must point to the valid PE header)
The relocation table must start from $40, but copied as is (no changes)
If needed the code section must be moved to satisfy paragraph (16-bytes) boundary.