Not quite right. Yes, using the same atlas will reduce draw calls, but it's using the same material that controls it, not the atlas.
So if you have 10 UITextures all using the same material, then you will only have 1 draw call.
I don't recommend creating atlases at run-time, but if you do, use the atlas maker as a guide. Don't try to convert it to be a run-time class, it's not meant for that.
All you need is to use Texture2D.PackTextures function to pack many textures into one. Doing so also gives you rects, in order of the textures you passed. Meaning the [2] index texture in your array will be using the rect[2] index.