If you want to do it legally, the first step is talking to the city (or county) planning/zoning/development office to see what the legal options are for converting garage space to an ADU (accessory dwelling unit).
Where I live, to have a legal/permitted ADU, it must be attached to the main house, must meet code requirements, must pass a period of time where neighbors have an opportunity to raise objections, must match the lines/character of the main house an neighborhood, and you have to complete an attestation every 2 years that you are residing in the main portion of the house. Currently we are also required to add off-street covered parking for an ADU (!?!?!). These requirements are extremely location-dependent.
For a duplex, you need to be zoned to allow a duplex, and may need separate metering for some utilities, etc. Duplex is more flexible in that you wouldn't need to occupy any part of the property yourself.
As far as doing it illegally (or unpermitted), a lot of people do that - I'm not conding or advising it. The risks depend a lot on the enforcement where you live. Even if you aren't doing it unpermitted, you still want to pay the appropriate income taxes, have a legally binding lease agreement, etc. You could even ask the zoning/development people how strict enforcement is in your area.