Diffuse interstellar band formation in dense clouds