We show that a network can self-organize its structure in a completely distributed manner in order to optimize its synchronizability whilst satisfying the local constraints: non-negativity of edge weights, and maximum weighted degree of nodes. A novel multilayer approach is presented which uses a distributed strategy to estimate two spectral functions of the graph Laplacian, the algebraic connectivity λ2 and the eigenratio r = λn/λ2. These local estimates are then used to evolve the edge weights so as to maximize λ2, or minimize r and, hence, achieve an optimal structure.