Yes, that's possible, but I wouldn't change it myself during the warranty period. Since the iMac is only accessible from the front, replacing it yourself is possible but also critical. However, specialist dealers offer this service. Be sure to make a backup beforehand.
Depending on the dealer, the cost is between 250 Fr and 450 Fr depending on the SSD size. However, you can also do it yourself, please watch the Ifixit or YouTube video.