The 240D is a car that was designed to be a reliable, comfortable and economical form of transportation. They are so solid that they feel like they're cast in one piece. But, they are not by any stretch of the imagination a great handling performance car.
If you want to spend time and money on an engine swap, I totally understand that urge, I've done a few in my life and they were not done out of practicality, but for the challenge of doing them. But, you can find jillions of cars better suited to such reengineering.
To begin with, due to several elements of the engine compartment, such as the steering box and the sway bar along the firewall, this would not be a very easy car to do an engine swap.
Second of all the rear axle and jack shafts were designed to handle no more than a little under 200 horsepower. That's what the six cylinder gas engine used in the 123 developed.
There are a few DOHC gas six cylinder 123's around that would give you a more powerful car if you're stuck on the 123.
My point is that these cars are GREAT for what they were intended, but you can come up with so many OTHER great cars, MB's included, for an engine swap that will give you a much more fun car to drive, probably with less time and money spent on them.
With that said, if you are still bent on this project, look through some old posts here for some information on a 4.X litre Chevy V6 into a 123 wagon. There is much detail offered including some good photographs. The gentlemen that did the swap apparently did an excellent job. I don't know if you have done such work before, if you have, I'm sure you know that you will need several additional skills beyond normal car maintenance and repair, including good welding skills/equipment.
Best of luck and keep us posted on your progress,