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.