I had an Apple-label Samsung SSD in a Mini go bad -- it could be read, sort of, but many disk operations were unsuccessful, and formatting it just crashed.
So I replaced it.
But eventually I was able to revive the Samsung by connecting it directly to SATA in a PC and formatting it as a Windows drive using a freebie Wintel disk formatter.
Then I was able to use a USB case to connect the SSD to a Mac and format it as APFS.