Can't reformat WD My Passport

I have an old WD My Passport and used it for a Windows PC. Now that I got a Macbook Air, I wish to reformat the WD My Passport to Mac version. Tried using disc utility to format; created the partition and didn’t seem to work. I kept getting an error message saying that “Partition failed” with error. Unable to write to the last block of the device.

Hi,

Can you please try testing the drive using first aid on the Mac. This will allow you to identify any specific issue on the unit.

See if the following link helps:
How to partition and format a WD drive on Windows and Mac OSX