You need an SSD from the same exact model to be sure of compatibility. Technically most any SSD from 2013 to 2017 will work when using Linux, but macOS will know the SSD is not correct and may even refuse to boot the macOS installer if a certain Apple OEM SSD is installed internally. This is from personal experience. Other Apple SSDs will work with macOS, but may have unknown issues since I did not test them thoroughly. I know another SSD not made for the 2015 laptop would fail the Apple Diagnostics even though the SSD was perfectly fine.
Some of the Apple OEM SSDs are indeed used in several different model Macs including desktop systems, but it is hard to figure out which specific model Apple OEM SSDs were officially supported for each system.
I did see instructions for running the system firmware updater by itself in order to update a Mac with a third party internal SSD installed, but it requires the system firmware to be at 195.0.0.0.0+. Here is an article with instructions with the relevant section about halfway down "For those without access to an Apple SSD...."
https://tinyapps.org/blog/202110270700_monterey-third-party-ssd
FYI, when using a third party M.2 SSD internally, it seems like the Sintech SSD adapter is the most reliable & compatible option. You definitely want to be careful when updating the system firmware this way since it could brick the laptop if the upgrade fails due to the drive (internal or external) disappearing during the process.