The sentence that requires revision to maintain a formal style is:
"The Duke of York was good friends with William Penn, and he signed a charter granting an expansive territory that became known as Pennsylvania."
This sentence can be revised to use more formal language by replacing "good friends with" with "had a close friendship with" or simply "was a close associate of." The revised sentence could read:
"The Duke of York was a close associate of William Penn, and he signed a charter granting an expansive territory that became known as Pennsylvania."