Doping of a solid with impurities
I give a very general answer: it depends on the solid and the dopant. 

One of the main issues is best viewed from a thermodynamic point of view: you want to create something similar to a solution. The dopant should randomly occupy some positions in the solid, and this should be comparably stable or more stable than the pure phases themselves. The dopant can substitute an atom (then it is often chosen to be with similar size and chemical properties), but it can go originally unoccupied places, too.
Some examples: 


You can introduce dopants with co-crystallization. You have a method to prepare the host solid through crystallization from its melt or from a solution, then you can mix the dopant during the synthesis, and if you are lucky it works. With molecular materials or simple inorganic salt, it can be a relatively easy process.
Chemical vapor deposition techniques are often used to create (doped) thin films.
Some dopants can be introduced by simple immersion. Hydrogen can diffuse inside of the host material, and act as a dopant in metals and other materials. The preparation can be just letting the sample stay in hydrogen gas for a longer period. Similarly, there are many oxides where oxygen acts as a dopant, and its level can be controlled by heat treatment in oxygen (or in a vacuum, to remove the extra oxygen). My understanding is that the boron doping in silica using diborane gas is also based on similar principles.