The performer borrows a hat — of any sort — and announces that he'll make an egg-cake inside it. He presents a plate with three eggs on it. He cracks the first egg on the plate and pours the contents into the hat; he picks up the second and cracks it too hard so that the contents spill all over the plate; he swears and ruefully says that he'll have to make a smaller cake; he cracks the third egg and pours it into the hat. He then passes the hat over a flame and removes a small cake which he can share with the audience. He then returns the hat to its owner with his thanks. The owner can testify that the hat isn't damaged and that there's nothing in it.
The first and third eggs are actually empty having been blown out before the performance and touched up at the ends to appear to be intact. Thus nothing is actually poured into the hat; the cake is dropped in under cover of some act of misdirection.
A little practice is necessary to be successful with this trick: the fact that the eggs are empty has to be concealed by appropriate hand positioning, accompanied by patter and misdirection.
If other egg tricks are being done, a basket of eggs with all the necessary "doctored" ones and untouched ones can be presented; apparently selecting eggs at random for this trick is very effective.
The cake in a hat trick, method 1, needs more equipment but can be made much more exciting with the judicious use of "sterilization" procedures.