Install nextcolud on a subdomain

I am currently using OwnCloud that was installed from cpanel on a subdomain of my webspace.

I wish to remove it and install NextCloud instead. Is it possible to use the setup-nextcloud.php file to install next cloud on a subdomain?

Yes, it is possible.

Or, what you could do:
Install into a subdirectory, e.g.

Then later configure your subdomain to point to this very directory.