You cannot be a cog in Toontown in normal play. What you can earn is a cog disguise, which lets you walk around looking like one — and there are four to collect.
Defeat ten Cog Factories in Sellbot Headquarters. Each one awards a suit part, and once you have the set you team up with seven other Toons to take on the VP.
Help shop owners throughout Donald's Dreamland. They hand out the twelve Cashbot suit parts, and with the full set you and seven others face the CFO.
Same structure, different neighbourhoods. Lawbot parts come from work in the Brrrgh, culminating in a fight against the CJ. Bossbot parts come from Donald's Dock, ending with the CEO — the hardest and most powerful cog in the game.
The disguises are the only legitimate route. Cheating to become a cog outside those four boss fights is detected, and the account is banned. The disguises are also genuinely useful: they let you enter cog-only areas and are required for parts of the endgame.