I am having a Gizmo app and I have a root GameObject with a prefab. I am able to duplicate the objects at runtime. I wanted to save user created objects into prefabs. How can I achieve this in Unity?
You can’t. Assets are generally read only in build games. Furthermore prefabs are an editor feature. At runtime a prefab is just a serialized off-scene gameobject which you can clone into the scene. You can’t create such off-scene objects at runtime. It also wouldn’t make sense as those can’t be stored anywhere as Unity doesn’t have any built-in way to serialize gameobjects at runtime.
If you need something like prefabs at runtime you have to serialize them on your own into your own format. Unity’s asset system / database is rather complex. If you want to mimic such an behaviour you should keep in mind what you need to serialize. The main problem are how to represent cross references between different serialized assets. A simple gameobject would consist of the actual gameobject / transform hierarchy tree but also any other components which might be attached to any of those objects. Furthermore those components can reference other assets like Materials, Meshes, Textures, …
If you only want support built-in basic assets you may just want to provide them in arrays so you can simply store the index of the used Mesh / Material / Texture / … However if you somehow want to support externally provided mesh data or texture data you have to store those as well where it gets really nasty…