There are two ways (I've never used a d500, but this should be true)
Either find an option to "Format SD Card" which will erase absolutely everything on the card (obviously make sure anything of value is moved to a safe place)
Or, when go to playback mode, and view one of the images that can't be deleted. Now find a button on your camera marked "AE-L/AF-L" and press it. You should see a key symbol appear or dissappear if you press the button a few times. When it's not visible, the image can be deleted normally. If the key is present, it prevents the image from being deleted. Go to each image and press the AE-L/AF-L button to remove the key, and you're sorted.