If the selector lever will not move from P using the proper shift procedure, continue to hold down the brake pedal.

Take the vehicle to an Authorized Mazda Dealer to have the system checked.
Shift-Lock System
Manual Shift ModeDSC HU/CM Inspection
1. Disconnect the DSC HU/CM connector..
2. Connect the negative battery cable..
3. Attach the tester lead to the DSC HU/CM wiring harness-side connector and
inspect voltage, continuity, or resistance according to the standard (reference)
on the table.
Standard (Reference)
...
Clutch Release Collar Inspection [C66 M R]
CAUTION:
Do not clean the clutch release collar with cleaning fluids or a steam cleaner
because it is filled with grease.
Operation Inspection
1. Turn the collar while applying force in the axial direction, and inspect for
sticking, excessive resistance, and an abnormal noise.
...
Cylinder Head Gasket Replacement [Mzr 2.0, Mzr 2.5]
WARNING:
Fuel vapor is hazardous. It can very easily ignite, causing serious injury
and damage. Always keep sparks and flames away from fuel.
Fuel line spills and leakage are dangerous. Fuel can ignite and cause serious
injuries or death and damage. Fuel can also irritate skin ...