is there a way to display powershell code in a code block with the correct visual elements to it (colour, font, etc)? We are moving to modern pages for our internal how to guides and this would help visually if possible.
One possible Solution would be to "pre-format" your code and then paste it into the new pages.
There are a lot of online and offline tools that could help with that.
The main issue you will have is the missing Script Editor Webpart or equivalent on the modern pages. I would suggest to use wikipages for information that inherits code snippets.
If you want to try how that could look like, test some of your snippets here http://hilite.me/ and copy paste the html information into the page.