Apple - Code markup in Apple Notes app
Notes in macOS High Sierra includes a Monospaced format.
In addition to the existing format types such as Title, Heading and Body, there is a new format named ‘Monospaced’. This format is a variation of the Body format but with a monospaced font family.
macOS High Sierra Hidden Features, Notes.app
Note: I am in no way connected to any of these software.
Boostnote is an open source project for writing notes with syntax highlighting. This is a good free alternative to using the native Notes app if you aren't against downloading an additional application.
Quiver provides features like LaTeX support, syntax highlighting, customizable themes, cloud syncing, and version control. As of writing this, it costs $9.99.
Bear provides syntax highlighting, easy exports (to PDF, .docx, HTML, JPG, etc.), multiple themes, and syncing through iCloud. As of writing this, it costs $1.49 per month (if paid monthly) or $14.99 per year (if paid annually). If paying monthly, you will get a free one week trial. If paying yearly, you will get a free one month trial.