It can happen with or without pregnancy. If it settles on it’s own, that’s okay. But if it gets bigger and becomes red and swollen, please see a doctor. You may need antibiotics. If it gets even worse, you may need a minor surgery to release the pus.
(You can read up on pilonidal cysts/abscesses)
Take care and hope it gets better soon