You can reach the egg only after killing the dragon. Once you are on your mission to defeat the evil dragon, you have to carry to a few blocks for building a piston and lever. Meanwhile, the egg will appear on the stack of bedrock in the middle of the end portal and then you can hatch it.