It is possible, Mazda built a concept 2 in 2011 that had the 2.3 MZR from the Speed3 (albeit with DI, but size shouldn't be significantly affected by that). However, that's not a common swap, to my knowledge it's never been done outside of that concept. Therefore, it will be very expensive, since all the mounting hardware, exhaust and probably intake will have to be custom made. You'll also need to find space for an intercooler (probably need a higher hood with a scoop to accommodate that), and a larger radiator in addition to the engine. The stock transmission and differential won't hold up to the extra torque, so you'll have to stuff an MS3 (or other, more robust aftermarket) clutch/transmission/diff combo in. To handle the additional power and weight, you'll want wider, gripper tires, and probably some stiffer springs and dampers. If you're doing anything more than highway pulls and tooling around town you'll want some good brakes, probably something bigger than stock.
If I walked into a shop and asked for it to be done, I'd be expecting it to cost 20k AT LEAST (25-30k with the suspension, tires and brakes). And it wouldn't be reliable, either. Swapped engines don't go through the thousands of hours of testing that the originals do, and little things like wires or hoses rubbing through and other annoying little problems happen all the time. Don't get me wrong, I think it would be an awesome swap, but you'd have to be very dedicated, willing to dump money, and it probably shouldn't be your only car for it to not become a major PITA. If you meet those requirements and decide to go through with it, please post a build thread.