They'll physically fit but the 5 is a lot heavier- so you really want shocks that are made for the MazdaSPEED 3, or the 5. Those are higher load shocks. Most shock manufacturers don't bother making separate versions for that chassis- they just throw one part number at the whole platform- but Koni does. Not sure it the STR line has two versions or not.
Went and looked them up...
2014 MZ5 Koni STR:
8750 1088L
8750 1088R
8050 1140
2014 MZ5 Koni Yellow:
8741 1490LSpor
8741 1490RSpor
8040 1354Sport
2012 MS3 STR:
8750 1088L
8750 1088R
8050 1109
2012 MS3 Yellow:
8741 1490LSpor
8741 1490RSpor
8040 1353Sport
2012 MS3 Red:
8745 1110L
8745 1110R
8045 1096
2012 MZ3 STR:
8750 1087L
8750 1087R
8050 1108
2012 MZ3 Yellow:
8741 1487LSpor
8741 1487RSpor
8040 1351Sport
2012 MZ3 Red:
8745 1110L
8745 1110R
8045 1096
So looks like Koni even split up different applications for damping between MZ3, MS3, and MZ5. They don't just lump the 5 together with the speed3 anymore.