I took a look at your script and problem in general, and I think you need to divide it up into smaller pieces. When designing a car, you don't make a whole working car and then put it in a wind tunnel to see if it's aerodynamic enough, you test and improve each component separately first. Same here - instead of putting the whole device together and optimizing it, which is a huge task, it's a lost faster, easier and simply better to build the device from optimized parts.
So, first you should make sure the 2D sheet itself has an optimal lattice constant and atomic coordinates. This can be done for what constitutes the electrodes, and better yet on just the primitive cell of the 2D material. That is, you optimize the size and positions of the cell with 2 atoms, I guess.
From that optimized unit, you build the 2D ribbon by repeating in A or B whichever makes sense (do not repeat in C yet), passivate it and (optionally, I would say) optimize again for edge reconstruction. I imagine this has negligible effect on the overall results, but for completeness I mention it here.
Now you can make a small repetition, maybe 2 or 3x in the C-direction and add the extra atom over the surface. To find its optimal position you can run a regular geometry optimization on this relatively small system, which is periodic in C (and A and B too). It is highly unlikely that the ad-atom has any influence on the lattice constant, so just a force optimization will be enough. Make sure the outer layers in C of the 2D material are fixed, for later use!
Finally, repeat the ribbon in C as much as needed. In the middle, remove a portion corresponding to the small repeated system with the ad-atom you looked at in the previous step but leave the atoms corresponding to the ones you fixed. Drop in the optimized structure - if you do it right, the fixed atoms will exactly overlap existing atoms in the structure, but that is easy to fix using the selection tools.
Now create the device and run it - there is no need to relax the whole device since each part is already optimized.