I own a basic 3D printer, and I do some 3D printing for my work.
Doing what you describe is much harder than you think.
For a newbie, there are way too many obstacles, and much too high a learning curve for you.
If you want to know the details:
- First, you have to be able to design the nut you need, exactly identical to the ones you need to duplicate. Your chances of going on the internet and finding that exact nut for 3D printing is low.
- Then, assuming that you have the correct design file, you have to print it in a material that will be suitable, just to see if it will fit. Most starter 3D printers print plastic materials, which probably isn't strong enough for your bike. 3D printing to duplicate metal parts is a very advanced method that requires very special (=expensive) printers that aren't for a newbie.
- And if your 3D printed nut isn't exact, you'll have to adjust your design and re-print until you get it right. Back to square one to try another print.
Having said all that, going through all that effort is probably not worth your time. You're better off taking the nut to a hardware store that specializes in hardware (nuts and bolts), let them identify the nut, and buy the nut from there.
Take trm's advice, above.