PROFIBUS Devices with M12 connections normally come with 2 connectors on the device, an in and an out. What you would need is a cable with M-12 for the in side and a another cable for the out side. M12 connectors come in “male” and “female” so make sure you have enough of each for your installation.
There are also M12 “T” connectors that allow you to disconnect the device from the bus without “breaking” breaking the “daisy-chain” on the bus.
Turck and Molex are two companies that have M12 connectors, “T” connectors, cables and terminators. I am sure there are other vendors as well.