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."
The phrase "good friends" is informal; a more formal wording could replace it with "had a close friendship" or simply "was a close associate."