Yes, this can be done, most commonly in conjunction with the use of a
WordPress multisite network, although you can also find tutorials via a Google search which allow you to make configuration changes to the core WordPress files which allow it also. Thanks.