Decide when to opt out of Medicare
It is possible to open your practice while remaining opted-in to Medicare. Simply don't accept any Medicare-covered patients. Instead just take their contact info and reach out to them again when you are able to opt-out.
On the other side of the coin, it's possible to moonlight as an employed physician even after opting out, though only in limited circumstances. These include positions in occupational medicine, correctional medicine, addiction medicine, and urgent care. Hospice care is also possible, but only if your position is administrative in nature. These options are outlined in greater detail here.
If transitioning a practice: notify your patients
Give at least 30 days notice, preferably in the form of a written letter (see this template from AtlasMD). Help any patients currently in the midst of major health issues find a new care provider, or you could be prosecuted under patient abandonment laws. Look up the laws in your state.
Complete an opt-out affidavit
Look up your state here to find a link to the proper opt-out affidavit and the address to mail it to.
Mail affidavit at the appropriate time
You'll need to know some details of the opt-out process. New "batches" of Medicare opt-outs are made active on the first day of each calendar quarter (Jan 1, Apr 1, July 1, Oct 1). The Medicare carrier must receive your opt-out affidavit 30 days prior to the stated effective date (Dec 1, Mar 1, June 1, Sept 1, respectively). So if you start the opt-out process on December 2nd, the earliest you can be officially opted out is April 1. Plan accordingly.
Send the affidavit to the proper address (listed by state here). I recommend using a method with a guaranteed delivery date and proof of delivery (such as Certified Mail, return receipt requested).
If you wish, include a cover letter requesting that the carrier acknowledge in writing that the opt out was properly accomplished.
Find an Advance Beneficiary Notice of Noncoverage (ABN) form online
All new patients must sign an ABN to acknowledge that you are opted out of Medicare. English and Spanish forms are available for download here.
Notify the state Medicaid program that you would like to privately contract with patients
This may require that you dis-enroll as there is no “opt out” process with Medicaid. Some states may ask you to sign up as an ordering and referring only provider. For details on this process within your home state, Google "[state] Medicaid ordering and referring enrollment".
See the full DPC Frontier dicussion on Medicaid here.