how to program a hdd

Can you provide more detail about what you want to do? An HDD can't be "programmed," unless you are writing microcode.

Do you want to partition and format a new drive? Do you want to install the operating system on it? Do you want to install some other software?
 
If you want to change some HDD internal parameters, modify SMART or HPA data you are going to have to get to a ATA terminal with something like MHDD or Victoria.
If you want control of the spindle assembly buy a COM-to-TTL converter, find the manufacturers specs and learn machine language.
Experiment with something like dfsee on an old HDD first.