Yes! I once had to merge a dozen or so repos into a mono repo. I don't have my script handy but git allows merging repos with unrelated histories into one repo while preserving the history.
If I remember correctly, this is how you do it:
1. Create a new empty repo for the monorepo
2. For each repo, 'git mv' all of the contents into a new directory with the repo's name
3. Add the repos to the mono repos as remotes
4. Run 'git merge --allow-unrelated-histories' for each repo
You will now have a monorepo with preserved history with each old repo existing inside of a sub-directory in the new monorepo
If I remember correctly, this is how you do it:
You will now have a monorepo with preserved history with each old repo existing inside of a sub-directory in the new monorepo