Yes, it is possible. Is it worth it? Some say no, I say no. Not onyl wil you have to buy the enigne, but you will need to redo all the engine mounts because of the i6 instead of the i4 engine, PLUS tranny. And the real kicker is the necessity for a overhaul ont he suspension to maintain the extra weight.
What is mroe economical is sellign your 318, and just buying a 5 speed 323, 325, or 328. A M3 is a bit pricier.
Id reocmend a 325 from 1994-1995.
1995 BMW M3 Turbo - Dakar/Black