Yes, you can definitely use a square pan to bake a cake in an oven. Baking a cake in a square pan is a common and perfectly acceptable method. The shape of the pan won't affect the baking process or the outcome of the cake, as long as the volume or capacity of the square pan is similar to the round pan size called for in the recipe.
Keep in mind that the baking time and temperature might vary slightly depending on the size of the square pan compared to the round pan specified in the recipe. A square pan might have more exposed edges than a round pan, which could lead to slight differences in the baking time. It's always a good idea to monitor the cake closely and perform the toothpick or cake tester test to check for doneness.
When substituting a square pan for a round pan in a cake recipe, you should use a square pan with similar dimensions to maintain the same baking results. Additionally, it's essential to grease and flour the square pan adequately or use parchment paper to prevent the cake from sticking.
In summary, using a square pan to bake a cake in an oven is a suitable alternative to a round pan, as long as you adjust for any potential differences in baking time and prepare the pan properly.