An egg in NetHack may be "just an egg" (presumably an ordinary unfertilised hen egg) or it may be the egg of a monster, in which case it might eventually hatch. When the egg hatches, the hatched monster may become your pet.
One in three generated eggs is from a non-unique non-aquatic oviparous species, picked following the normal random monster generation for the current level. The species of monster eggs can be identified with a scroll or spell of identify; if the post-identification type is still just "egg" it is not a monster egg, if it is a monster egg you will now recognize the type in the future. Monster eggs can also be identified by seeing one hatch. Polymorphing into the adult form (regardless of gender) of an oviparious monster will identify all future eggs of that type. Polymorphing into any type of adult dragon will identify all types of dragon eggs as well.
Note that although eggs are surprisingly efficient on the nutrition/weight ratio, eating them can be dangerous. They may be rotten, in which case you will vomit and should have a unicorn horn handy, or on the later levels they may be cockatrice eggs, which will cause delayed stoning if you eat them. If you are already satiated, you won't get a warning about eating an egg, even if it would choke you to death. It is safer to leave eggs around as food for carnivorous pets. (Don't throw them though - eggs you throw will break 99% of the time.. Just drop them on the ground and let your pet eat it.)
If you polymorph into a female Oviparous monster, you can lay an egg with the #sit command, and when it hatches it will become your pet. Laying an egg will reduce your nutrition by the nutrition value of an egg. There is no luck penalty for eating your own eggs, but there is for breaking them.
A randomly generated dragon egg will also become your pet if you are carrying it when it hatches. If you are male, there is a 50% chance that any egg which hatches while you are carrying it will become your pet. If an egg will hatch, it will do so after no less than 151 turns, and no more than 200 turns. Therefore it may be useful to #name a found/created egg with the current turn. Winged gargoyles lay very few winged gargoyle eggs - 76/77 (approx. 98.7%) of the time the egg will hatch into a gargoyle.
Eggs will only hatch if in your inventory or on the floor. They will not hatch if kept in a container, but will still age; if they are left inside longer than it would normally take them to hatch, they will become rotten. If they are lying on top of ice, they will mature more slowly than if on regular floor. Like corpses, they will not age at all in an ice box.
Cockatrice eggs are popular as projectiles that will petrify any stoning-susceptible monsters they hit (referred to as "grenades" in this role). When you throw an egg, there is a risk that it will miss its target and go to waste, so you may prefer to wield the egg. Unlike wielding a cockatrice corpse, this does not have the risk of petrifying yourself. If using cockatrice eggs that you have laid yourself, note that there is a Luck penalty for breaking your own eggs. Note that you can wield an entire stack of eggs, causing them all to break in a single attack. If you break a stack of your own eggs, the luck penalty is -1 for each egg, up to a maximum of -5.
But I asked why not keep it and let the hen sit on it till it
hatched, and then we could see what would come out of it.
"Nothing good, I'm certain of that," Mom said. "It would
probably be something horrible. But just remember, if it's a
crocodile or a dragon or something like that, I won't have it
in my house for one minute."
- mksobj in NetHack 3.4.3, line 423
- breaktest in Dothrow.c
- obj.h in NetHack 3.4.3, line 208
- sit.c in NetHack 3.4.3, line 303
- dothrow.c in NetHack 3.4.3, line 1588
- timeout.c in NetHack 3.4.3, line 432: The identity of one's father is learned, not innate
- obj.h in NetHack 3.4.3, line 207
- timeout.c in NetHack 3.4.3, line 389
- mon.c in NetHack 3.4.3, line 2596
- dothrow.c in NetHack 3.4.3, line 1588
- uhitm.c in NetHack 3.4.3, line 757