Your question is a bit sparse with respect to how you created the Ubuntu installer and the current state of your drive.
Most users attempt to remove linux partitions using either the Disk Utility application or the
diskutil command. Often this results in failure.
Actually the result may be 100% failure, but I can not know that because those who succeed are not apt to post a question here at Ask Different.
An alternative would be to boot to a Live version of Ubuntu and use an application or command to remove the linux partitions. I usually use the command
gdisk. Once the linux partitions are removed, the free space can be added back to the macOS partition. For example, if you are using APFS, then the usually command is shown below.
sudo diskutil apfs resizecontainer disk0s2 0