Density dependence of thermal conductivity in nanoporous and amorphous carbon with machine-learned molecular dynamics