If you create a new device or process, it's called an invention. Many futuristic inventions from science fiction have come true, though no one has successfully invented a time machine.
The act of inventing something is also referred to as invention. Your invention of an amazing new cookie might make you the hit of the bake sale. Something imagined or created in your mind can also be called an invention. The story of what happened to your homework may have been a complete invention, but it was probably entertaining for your teacher — especially the part about the alien abduction.