Is there a way to export all my notes written in the Notes app in any format so that I can import them to another Mac?
1 "is there an option to save notes to iCloud?" yes, in system preferences-> iCloud.
2 "it seems I cannot import a pdf to notes" you can. The regular method of File-> import->import file, won't work. You can drag and drop multiple files into a note.
3 "Scripting" that would be a task for automator which even I have to learn yet.
4 "how to import to new Mac," if same Apple ID is used on both Macs, turn on the iCloud for notes (see 1^) It'll sync. If different IDs are used, it is not a tried method. You can add collaborators (or people) and send them the invite. Then they can import all the notes to their Mac.