I think this question has come up a few times already, see for example the answer here: DICOM export of segmentation node.
Slicer can build a CT image from scratch. I would recommend to start with exporting from GUI first, and once it confirmed to be working as expected, do the same using Python scripting.
Let us know if you have specific questions.