Using this PUT /me/drive/items/{parent-id}:/{filename}:/content
Graph API you can create docx file, set its content and upload it to OneDrive.
In body, select binary as format and attach file with content.
Please refer to the below sample screenshot.
Please note: To upload large files you need to use Upload Session, Please refer to this documentation for more details.
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.