Disordered forms of carbon are an important class of materials for applications such as thermal management. However, a comprehensive theoretical understanding of the structural dependence of thermal transport and the underlying microscopic mechanisms is lacking. Here we study the structure-dependent thermal conductivity of disordered carbon by employing molecular dynamics (MD) simulations driven by a machine-learned interatomic potential based on the efficient neuroevolution potential approach. Using large-scale MD simulations, we generate realistic nanoporous carbon (NP-C) samples with density varying from $0.3$ to $1.5$ g cm$^{-3}$ dominated by sp$^2$ motifs, and amorphous carbon (a-C) samples with density varying from $1.5$ to $3.5$ g cm$^{-3}$ exhibiting mixed sp$^2$ and sp$^3$ motifs. Structural properties including short- and medium-range order are characterized by atomic coordination, pair correlation function, angular distribution function and structure factor. Using the homogeneous nonequilibrium MD method and the associated quantum-statistical correction scheme, we predict a linear and a superlinear density dependence of thermal conductivity for NP-C and a-C, respectively, in good agreement with relevant experiments. The distinct density dependences are attributed to the different impacts of the sp$^2$ and sp$^3$ motifs on the spectral heat capacity, vibrational mean free paths and group velocity. We additionally highlight the significant role of structural order in regulating the thermal conductivity of disordered carbon.