No. A standard M.2 SSD will not work in an iMac without the use of a third party adapter, as they didn't have M.2 slots back in 2014. Plus you need to make sure the iMac's firmware is up to date so it can communicate with an NVMe SSD. You will only be able to use macOS 10.13+ on this iMac when used with an NVMe SSD.
You would be better off with a standard SATA SSD, something like
WD Blue (1000 GB, 2.5") as it will get in place of iMac's HDD. You can find how-to instructions on YouTube.