Replace faulty device / disk on linux raid | MDADM

identify the faulty disk, maybe you already have logs or you do some long SMART health tests
smartctl -t long /dev/sdd
flag the disk as failed if not already
mdadm --manage /dev/md0p1 --fail /dev/sdd
and remove it
mdadm --manage /dev/md0p1 --remove /dev/sdd
disconnect the disk and connect a new one
copy the partition table (gpt in this case) from another disk of the raid
sgdisk /dev/sda -R /dev/sdd
add the new disk to the raid
mdadm --manage /dev/md0p1 --add /dev/sdd