If you can, contact your surgeon’s office and ask. Different people seem to have different restrictions on this.
With hip 1, I was fed up with the back position and contacted my OS after only 2 weeks. The response was I could sleep on the non- operated side with a pillow between my legs, or on the operated side. I was delighted, until I tried it, and found both positions very uncomfortable. By 12 weeks, I was sleeping on my non-op side ok but fed up with the pillow. I asked for permission to skip the pillow and was told to wait till 16 weeks.
With Hip 2, same approach (posterior) but different surgeon, there were no restrictions after 6 weeks. After my previous experience, I didn’t bother trying that soon. I’m not sure just when it came, but by 13 weeks (3 months) I was happily sleeping on either side.