The M52 came in E36's so yes it will fit no problem.
The Getrag 250 used in 318 and 325 models of the E36 era will bolt up to M52 blocks, but are a bit weaker than the ZF used on 328 and M3 models.
You'll want to swap differentials as well, which means driveshaft, axles, and diff itself.
Obviously you will need the wiring harness and ECU from the M52 as well.
Basically, keep the 318 as a 318. Going out and buying a 328 would be way easier, and cost less for the same thing. Only difference is, it was done by the boys in Munich, so you know it is right.
If you want more power, keep the M44, and turbo or supercharge it.