Ideally, I think you would want each Mega to work out for itself what was connected to it, so no configuration was needed at all.
For some types of sensor, that's easy. If you could use only i2c sensors, for example, each sensor should have an address on the bus which would identify what type it was. For example, an sht21 temp/humidity sensor has address 0x40.
Many i2c I/o chips have a number of addresses (e.g. 8 ) which you can choose by setting pins of the chip. If you use those, you could decide that address 5 was for a chip that controls relays, and address 3 for a chip to which simple sensors are attached, such as door or window open sensors.
Your sketch could scan the bus at startup and record what addresses responded, which would tell it which devices are connected to this Mega.