First you would need to attend medical school (4 years) and match into dermatology residency (4 years), which is competitive.
Part of dermatology residency is where you learn the cosmetic procedures. Once you are out of residency and practicing independently you can then start doing cosmetic procedures as part of your practice.
If you enjoy cosmetics, you can also become a dermatology Physician Assistant and try to find a job that would allow you to perform cosmetic procedures. You can also perform many cosmetic procedures as a Registered Nurse.
Side note: there are many physicians who end up taking certification courses in cosmetic procedures and then they change their practice and call themselves a cosmetic dermatologist. Famous example is Dr. Simon Ourian who is notorious for his work with the Kardashians - he was trained in internal medicine but now practices as a cosmetic dermatologist.