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 ModeSeat Weight Sensor Inspection [Two Step Deployment Control System]
CAUTION:
If any of the following work is performed, perform the seat weight sensor
inspection using the M-MDS.
Removal of the passenger-side seat
Loosening and retightening of passenger’s seat fixing bolts
Or, the vehicle is involved in a collision
...
Ignition Coil/Ion Sensor Removal/Installation [Skyactiv G 2.0]
1. Remove the battery cover..
2. Disconnect the negative battery cable..
3. Remove the plug hole plate..
4. Remove the plug hole plate bracket..
5. Remove in the order indicated in the table.
6. Install in the reverse order of removal.
1
Connector
...
Sunroof Unit Disassembly/Assembly
NOTE:
If the guide or sunroof motor is removed, the glass panel will not be positioned
properly after the re-installation. To ensure proper positioning of the glass
panel, place alignment marks on the guide pin and frame before removing the
guide or sunroof motor.
1. Disassemb ...