How did you try to reinstall macOS - using macOS Recovery?
About macOS Recovery - Apple Support
If just choosing "Reinstall macOS" is not successful, try using Disk Utility first to delete the built-in drive. To do so, first switch to the "All devices" view (View menu > Show all devices). You will see the drive (named, for example, "APPLE SSD AP0256J Media") on top and below that, the disk2 container.
To delete the entire drive, right-click the drive on top (in my example, "APPLE SSD .....") and choose Delete. Deleting the drive will also automatically create a new volume. The name you enter will be for the newly created volume, so choose for example "Macintosh HD". After the new volume has been created, you should be able to reinstall macOS.