We develop a formalism for calculating cosmic microwave background (CMB) temperature and polarization anisotropies in cosmological models with Brans-Dicke gravity. We then modify publicly available Boltzmann codes to calculate numerically the temperature and polarization power spectra. Results are illustrated with a few representative models. Comparing with the general-relativistic model of the same cosmological parameters, both the amplitude and the width of the acoustic peaks are different in the Brans-Dicke models. We use a covariance-matrix calculation to investigate whether the effects of Brans-Dicke gravity are degenerate with those of variation in other cosmological parameters and to simultaneously determine whether forthcoming CMB maps might be able to distinguish Brans-Dicke and general-relativistic cosmology. Although the predicted power spectra for plausible Brans-Dicke models differ from those in general relativity only slightly, we find that MAP and/or the Planck Surveyor may in principle provide a test of Brans-Dicke theory that is competitive to solar-system tests. For example, if all other parameters except for the CMB normalization are fixed, a value of the Brans-Dicke parameter ω as large as 500 could be identified (at the 2σ level) with MAP, and for Planck, values as large as ω≃3000 could be identified; these sensitivities are decreased roughly by a factor of 3 if we marginalize over the baryon density, Hubble constant, spectral index, and re-ionization optical depth. In more general scalar-tensor theories, ω may evolve with time, and in this case, the CMB probe would be complementary to that from solar-system tests.