1. Start by ensuring that you have the original keyless entry remote and the master key for the vehicle.
2. Inside the car, hold down the unlock button on your master key and switch the ignition on and off twice within a few seconds. This puts the car in programming mode.
3. Press and hold the lock button on the keyless entry remote you want to program. While holding that button, press and release the unlock button three times within a few seconds.
4. Release both buttons and wait for the car's security light or central locking system to flash or respond, indicating successful programming. This may take a few seconds or up to a minute.
5. Test your programmed keyless entry remote to confirm that it locks and unlocks the car properly.
Note: If you encounter any issues during programming, you may need to repeat the steps or consult your vehicle's user manual for specific instructions related to your model and year of Mazda 6. It is also a good idea to ensure that the battery in the keyless entry remote is properly functioning.