I would like to make a script that will, from one input sample, generate all samples for each pitch/note (do re mi...). What is the algorithm for doing that?
There's different algorithms that can do what you want.
So, let's say, you got a got that emits a known pitch, C.
C has a certain frequency on the usual tone scales, 261.626Hz. You want to pitch it up one octave? sure, just double that frequency. You can do that rather easily by multiplying your goat sample with a 261....Hz tone. Now, downside of that is that, for example, a low-frequency hum at 50Hz present in the original sample will suddenly be present as a 311Hz tone -- and clearly disturbing your audio perception. Also, for pitches, not only the fundamental tone, but also the harmonics, i.e. the multiples of the fundamental, are important. Now, the harmonics of 261.6Hz are $2\cdot,3\cdot,4\cdot,\dots\cdot 261.6Hz$, whereas the harmonics of 623.2Hz (=c) are $2\cdot,3\cdot,4\cdot,\dots\cdot 523.2Hz$. However, by shifting both the fundamental and its harmonics up by 261.6Hz, you end up with $1.5\cdot,2\cdot,2.5\cdot,3\cdot,3.5\cdot,\dots\cdot 523.2Hz$, which will sound strange. So that's not really a solution.
Another solution that "doubles" all the frequencies is just what happens when you play an LP record at twice the speed it should be played; digitally, you can achieve that by decimation of the original signal. Now, if you play that goat record at twice the speed, it will only be half as long. So that's not the whole solution either. Notice how when you listen to heavily autotuned songs like Dayum you seem to be able to hear some kind of "vibrato" in the longer-stretched high pitched tones?
My guess is that autotune algorithms try to first convert the tone to the desired frequency (possibly through frequency, or cepstrum transformations), and then match the original tone duration, which leads to periodicity of $\frac{\text{original length}}{\text{in/out frequency ration}}$.
So, this is a complex topic, and there's not a single solution to the problem -- after all, music is art, and to me all the autotune pop/house sounds terrible exactly because of this "mechanical" vibrato. Other folks really like that; it's a question of taste and preference. I'd say: get a well-trained goat. Make it emit a few different sounds. Analyze the sounds. Understand how a goat sound works: What's its start/cadence? How does the signal look like if the goat gives you a long C, compared with a short C? Can you manually make the C longer by copy&pasting without sounding awkward? Then, you might have a chance of making an aesthetically pleasing goatophone.