A general theory of the modulation response and noise of multielement semiconductor lasers is presented based on a transfer-matrix method combined with the Green's function method. An arbitrary laser structure is represented by an assemblage of stacked layers, each of which is assumed to have uniform carrier density and noise sources. A rate equation for the electric field envelope is derived, with which analytical expressions for the small-signal modulation response and the intensity and FM noise are derived in terms of the transfer-matrix elements. The theory can be applied to DFB and DBR lasers, coupled-cavity lasers, multielectrode lasers, and vertical-cavity stacked-layer lasers as well as Fabry-Perot lasers. One of the main advantages of this theory is that the longitudinal cavity effect is incorporated by a simple multiplication and summation of the transfer matrices corresponding to the individual laser segments.