Yes, you can stay in Urubamba or Ollantaytambo in the Sacred Valley before the trek. The pickup time from the Sacred Valley will be 1.5 hours later than from Cusco.