Is it possible for a rib injury to cause pericarditis?

Yes but rarely. Blunt trauma to the chest, with or without rib injuries, is a recognized but rare cause of pericarditis.
Yes. It is usually the issue that caused the rib injury that is the culprit. Blunt force trauma to the chest can cause educational injury, inflammation, and pericarditis. Treatment is based on the cause, and normally resolves by itself. Otherwise, non- steroidals such as Motrin will do well.