Welcome! Good thing you have a little more 'warranty' than us original 2016 buyers since 3 years warrantyis out or almost out for most of us. Its a known issue as you probably have seen around here for quite a few 2016's, mine included

. Depending if you got it from the mazda dealer or a 3rd party used car place is where you will run into a complex scenario. If you take it to the dealer, they *should* do the dye test and probably find a leak of some sort. A used car place is going to push back on repairs since thats what they do and you might have to coordinate with the dealer and seller to work something out. If it is still under the original 3 year warranty you are in luck, if not then you have to push liability on the seller - this is why its easier if you bought it used from the dealer as opposed to a 3rd party seller. Mind you this will not be covered under the larger 5( or 10? i cant remember but its probably 5) powertrain warranty so its imperative this is taken care of asap if within the 3 yr warranty on stuff like this.
If you bought it from a private sale/ local guy or if the car was EXPLICITLY sold as-is then its just the dealer trip since the seller will most likely deny any liability or responsibility for repairs. Either way go to the dealer at least once since they would have to quote you a repair and you are required to sign off on it before they work (at this point you can choose to walk away from the repair job if its stupidly pricey). While you are there have the service department print out a warranty sheet on the vin if possible and keep that around since itl be handy to have. If you still have even a few days of the original 3yr warranty, the most important thing is to get that initial service check if its still covered since then you have evidence that the issue existed prior to warranty ending and they would be required to repair it. Source: I found the ac issue literally 6 days before the warranty ended.
Best of luck!