Though not based on a book or short story, this seems to have deep similarities to an R.L. Stine work - a boy encountering then forming a bond with a creature hatching from an egg and going up against scientists for its sake, like in the Goosebumps book "Egg Monsters from Mars".