Electromagnetics of two-dimensional materials with time-varying carrier density