This is how I see it (then it's gotta be that way :lol: )
There's a microprocessor inside, with a ROM that contains the melody. There's a buzzer that reproduces that melody. There are several ways to do that, but I guess the easiest would be PWM (Pulse Width Modulation). The buzzer is turned On and Off using a squarewave, but since it's duty cycle changes all the time, the actual sound from the buzzer is different (kindda approximation of a sinewave with a squarewave).
Another way would be to have a ROM with melody and a shift-register that will read that memory and send ones and zeros to the buzzer.
I don't think that you can modify one (to add your melody), since it's all inside 1 chip, that chip is unknown, it's programmed during fabrication process (the ready-made program with music is put inside, rather than programming every chip afterwards) and the memory inside is Read-Only.
You could build one actually, with a PIC microprocessor. Check out this website, really interesting:
**broken link removed**
You could use one of those small, 8-pin pics for that (12f series). And if you go with SOIC, then the design will be even smaller.
Good Luck,
TI|CP