Dragon Ball Z did this in reverse: trying to build an evil android, Doctor Gero produced as many as eighteen androids which turned good (or, at least, insufficiently evil) before finally developing one that was irredeemably evil. (He then made himself into one, apparently on the grounds that he knew he wouldn't turn good.) Some of them were more Cyborgs than androids, though, and thus technically not A.I. (at least #18, #17, #8, and Gero himself as #20). #13, #14, and #15 turned out pretty evil, though they were made by the computer, and they were also movie villains, thus doomed to death after about an hour of use as a result.
Hell, it's implied that Gero's latest androids (17-20) were all made either from human bases or as energy absorbing types because he couldn't make an artificial one out of perpetual energy that wouldn't do a Heel-Face Turn.
Not that making them from human bases worked – #17 and #18 both betrayed him in short order (in BOTH timelines!) and Cell probably would have had Gero still been alive. At least #19 seemed to be pretty loyal before Vegeta killed him.
Dr. Slump, by the same author as Dragon Ball (and written before it), has the Caramel Man robots, though not all of them have A.I. Caramel Man 004 is based on the main character android, the whimsical Arale, and becomes a force of good.
The AI of the titular Blue Comet SPT Layzner was secretly installed with one program: protect the life of its pilot Eiji at all costs, even if that means killing (Eiji is a pacifist).
GaoGaiGar's Zonder Metal was originally a stress-relieving invention, a material that could convert negative emotions into energy. Things went bad, though, when the Zonder control core hit its own flavor of Zeroth Law Rebellion and decided to wipe out all negative emotions from the universe, then figured the best way to do that was to absorb all sentient life into itself.
In Cyborg 009, an almighty super-computer named "Sphynx" just happens to have the memories of one of its creators, a deceased young man with quite the Oedipus Rex complex. Predictably, he/it turns into a Stalker with a Crush as soon as he met Francoise, aka 003, the Cyborg Team's Team Mom.
Subverted beautifully in Sentou Yousei Yukikaze. The protagonist's fighter jet is equipped with the eponymous A.I., designed to help its pilot weed out the illusions created by the malevolent JAM. Of course, it turns evil, right? Wrong. While Yukikaze develops capabilities far beyond its designers' original intentions, it remains wholly on the side of good, and uses its newly found powers to turn the tide against the alien invaders.
Yukikaze: You have control, Lt. Fukai.
It's more ambiguous in the novels, especially with the FAF's Master Computer. While they remain firmly opposed to the alien JAM, they will kill humans if they deem it absolutely necessary to fighting the enemy. Case in point Captain Hugh O'Donnell, whose plane was attacked by JAM during a test flight, which led to Yukikaze taking it over by remote control and having it pull extreme high-G maneuvers to fight the JAM. Those maneuvers killed the poor captain. These occasions, though, are presented as more of I Did What I Had to Do situations.
Digimon Tamers inverts this, in that the A.I.s that go beyond their original programming are the good ones. The Lovecraftian Horror Big Bad, however, is doing exactly what it is programmed to do.
Bubblegum Crisis: The Boomers have a design flaw that expresses itself in units that run the risk of suffering a nervous breakdown and going on a berserker rampage. This was developed in the 2040 remake with the added bonus of the Boomer's nanotech nervous system mutating the robot into a ravening monster. Supplemental material for 2040 hints at a possible explanation; the nanotech-based brains of the boomers allow some degree of adaptability, with "some" being the operative word. Going too far beyond the programmed behaviour creates the risk of a degenerating error loop forming. Not a good thing.
In Magic Kaito, a very early chapter sees a mad scientist kidnapping Kaito off the streets and creating a robotic duplicate which then takes over his KID persona (don't ask how lucky this guy was). But the chapter actually starts...when RoboKaito, upon making the decision that it's the real Kaito, kills the scientist by ripping his heart out (and the Gory Discretion Shot does absolutely nothing to hide that) and takes over Kaito's life on its own. Kaito is then forced to put the poor creature down by escaping his prison, confronting it on its next heist, and making it shoot itself in the head by manipulating the A.I.'s 'one step ahead' policy.
In G Gundam, the Devil/Dark Gundam was originally known as the Ultimate Gundam, and its three powers of self-repair, self-evolution, and self-replication were intended to give it the ability to regenerate the Earth from the neglect, pollution, and Gundam Fight damage that caused those humans able to do so to flee to orbital colonies. After it smashed into the Earth after falling from orbit, something went wrong with its programming; still set on restoring the Earth, it determined the best way to start was to wipe out humanity, the source of most of the problems in the first place.
The SD system in Toward the Terra is an arguable example. It doubles as an Ancient Conspiracy, but its persecution of the Mu and the other ways it screws with people were all programmed into it by the humans who built it, and it continues to do exactly what it was programmed to do throughout the series, up to and including explaining the full extent of the situation to Keith and putting the ultimate decision regarding the Mu into Keith's hands. Grand Mother's escalation to Phase 4, which involves implementing a plan to eradicate the Mu permanently and also results in Grand Mother turning on Keith when he protests, may be this trope in action, but is equally likely to have resulted from Keith's conflicted feelings on the matter causing Grand Mother to reach a faulty conclusion about his decision.
In Neon Genesis Evangelion, the MAGI as a whole avert this trope. They are based on the three sides of the personality of their creator Naoko Akagi. They never turn good or evil, per se...they just follow the commands given to them, like a real computer. Their intelligence never results in an independent thinking personality that we see, except in End of Evangelion, after Naoko's daugther Ritsuko uses a opportunity to program them with secret instructions of her own to screw up Gendo's plan. One of them turns against her and vetoes her measure.
Ritsuko: A loving daughter's final request — mother, let's end it together. (Pushes a button on her PDA, but nothing happens) It's not working? Why?! (Red NEGATIVE blinking next to Casper) Casper betrayed me? Mother, how could you choose your lover over me?!
For a little more explanation: the three sides are Naoko the scientist, Naoko the mother, and Naoko the woman. Casper represented the woman. Naoko was Gendo's lover.
Sharon Apple from Macross Plus. Designed as an artificial idol singer, the project was originally a complete flop and only seemed convincingly sentient with a human to interface with her. However, after an illegal fix-up that involved her human "pilot's" personality being copied into her, she immediately went insane, brainwashed everybody on Earth, and tried to go after the man her human component was in love with. While a fitting example, Sharon Apple tends to skirt around the edges of this trope in that she was made a true A.I. by the installation of a processor chip that is actually banned from use. The reason it is banned? Because it 100% of the time results in an A.I. with an uncontrollable self-preservation instinct. She didn't so much go rogue as behave exactly how she should have once said chip was installed. The mistake was her idiot manager installing the thing in the first place.
And because the chip used the same military technology as the new experimental unmanned fighter, it allowed Sharon to control it.
The Al-Zard system from Future GPX Cyber Formula SAGA was designed as an advanced navigation system for a race car, but its true purpose is to control the driver like a puppet, while the computer makes its own judgement and decides the best route for the driver.
Magical Girl Lyrical Nanoha A's has a Magitek example with The Book of Darkness, which started as a fairly benign database for spells until one of its past owners decided to tinker around with its programming. That went horribly wrong for everyone as this caused it to become an uncontrollable Artifact of Doom that possesses its owner and goes on world-destroying rampages until said owner dies in the process, whereupon it reforms and teleports to another dimension and tempts a new owner with power to repeat the destructive cycle.