We tried this a bunch and our drummer kept going well out of time with it, and we all did actually (we are Not Good musicians though), I ended up just playing the looped part manually instead Quite fun and meditative actually. It can be done though. Most loop pedals even have a little tempo knob for you.
I tried this in my old teenage band, we had a song where I did one riff over and over and then when I bought a loop pedal I decided to loop the riff and do other stuff over it. But the loop always ended up going wildly out of time for me and I had to frantically stop and start it repeatedly every couple of bars to get it back in time.
Luckily the singer/main songwriter really liked the effect of that so I kept doing it
I would get a looper that allows you to adjust the tempo whilst you are playing back the loop. So, record your loop, and then tap tempo to keep it in time to the drums. I think EHX Stereo Memory Man with Hazarai and boss rc 202 lets you do this without pitch shifting.