Well for a start it depends on the age of the Z3. The ones with M52 engines (ie, most) have a throttle cable and a different engine management system IIRC. The later M54 engined cars moved to drive-by-wire. Therefore two similar generation engines are a more straightforward swap as you don't need to go for a full conversion electronics wise.
The majority of Z3's are M52 engined, only the facelifted models made in the last 2 years of Z3 production or so had M54's (2.2 or 3.0).
In theory something like the 260-280bhp Alpina 3.2 or 3.3 engine will not be too much of a problem to fit into an older Z3, provided you can find one. They don't fit easily into the newer ones for the above mentioned reason.
Then you've got the issue that the Z3 was never available with a diesel engine and the 335d engine was only available with an automatic transmission of the type never fitted to the Z3. So you'd need a complete transmission swap as well. The newer autoboxes (It's a ZF 6HP26) are not cheap and neither is the 335d engine itself. So, even if you did manage to get around the issues the cost of the gearbox/engine will be thousands and thousands of pounds.
And then of course you have the point that the Z3 is a small roadster and the M57 is a big diesel engine designed for and intended for heavier, bigger saloon cars. It's just not a good match. You don't want that sort of power delivery in a convertible sports car. Any economy benefits are massively, massively cancelled out by the sheer enormity of the task at hand at associated costs anyway so you end up with a diesel powered Z3 for... what purpose? To annoy people with meaningless flywheel torque figures? Can you imagine an automatic diesel small roadster? I can sort of - only sort of - get the appeal in a 635d cab because it's a big cruiser. The Z3 is anything but. Infact it's a pretty crap cruiser.
You might as well just buy a Z3 3.0i or a Z3M. Both have ideally suited engines to the type of car it is already and by virtue of its light weight, both deliver quite sterling performance. If you do want to do an engine swap I'd look into the Alpina sixes perhaps.