Recent experimental advances enabled the realization of mobile impurities immersed in a Bose-Einstein condensate (BEC) of ultracold atoms. Here, we consider impurities with two or more internal hyperfine states, and study their radio-frequency (rf) absorption spectra, which correspond to transitions between two different hyperfine states. We calculate rf spectra for the case when one of the hyperfine states involved interacts with the BEC, while the other state is noninteracting, by performing a nonperturbative resummation of the probabilities of exciting different numbers of phonon modes. In the presence of interactions, the impurity gets dressed by Bogoliubov excitations of the BEC, and forms a polaron. The rf signal contains a δ-function peak centered at the energy of the polaron measured relative to the bare impurity transition frequency with a weight equal to the amount of bare impurity character in the polaron state. The rf spectrum also has a broad incoherent part arising from the background excitations of the BEC, with a characteristic power-law tail that appears as a consequence of the universal physics of contact interactions. We discuss both the direct rf measurement, in which the impurity is initially in an interacting state, and the inverse rf measurement, in which the impurity is initially in a noninteracting state. In the latter case, in order to calculate the rf spectrum, we solve the problem of polaron formation: a mobile impurity is suddenly introduced in a BEC, and dynamically gets dressed by Bogoliubov phonons. Our solution is based on a time-dependent variational ansatz of coherent states of Bogoliubov phonons, which becomes exact when the impurity is localized. Moreover, we show that such an ansatz compares well with a semiclassical estimate of the propagation amplitude of a mobile impurity in the BEC. Our technique can be extended to cases when both initial and final impurity states are interacting with the BEC.