It costs as much money as you spend on it. It depends on what you buy for coding the game engine. Making a game engine is a hard task, and they are often made with multiple experienced coders. I would suggest if you were to ever think of making one, you gain a lot of experience with coding and familiarize yourself with how everything your game engine uses works. It really depends, but if anything, it is much easier to buy a game engine.