cPanel does not provide an official uninstaller. If a cPanel installation fails, the usual recommendation is to reinstall the entire server.
However, it is possible to clean the existing installation and reinstall cPanel without formatting the server.
This guide explains how to remove the broken installation and perform a fresh install.
This process removes cPanel, MySQL/MariaDB, and all related data. Only use it on servers where data loss is acceptable or backups exist.