The folks at CNCDudez have been experimenting with cakes. Frosting cakes, actually. With a 3D printer. Spokesman Sean says:
We have seen videos showing chocolate being extruded out of a syringe and also cake dough being extruded to make cookies. But we wanted to see if we could Ice a cakes, buns etc etc. So - we attached an Icing/Piping attachment to a custom bracket we made for our 3D Printer.
The results are, well, messy, but evidently tasty. They had issues with "dry icing" and ended up inventing a "punch and extrude" approach that required rewriting the geode that controls machine movements.
Be sure to watch their videos to see exactly how messy this can be.