Polymode
Polymode might serve your purpose here. It supports editing documents that combine code in different languages. It does a lot more than just let you tweak autofilling, so it might be worth spending a bit of time to investigate.
Basically, it allows you to edit your document in one major mode, and seamlessly switch to a different major mode when editing code blocks. You can then turn auto-fill on in your 'host mode', and turn it off for the 'inner mode'. At the same time, you get the syntax highlighting and keyboard shortcuts you normally use for editing your code, without requiring you to use the same shortcuts and highlighting for the surrounding text.
Your example looks like a markdown document with a code block in programming language. There may already be a polymode for this combination - Poly-markdown already exists, and can be combined with Poly-R to get support for R code in markdown code blocks, for example. If the appropriate combination doesn't exist, it's relatively easy to make your own. The polymode manual is the best place to get started.
Orgmode
As NickD points out, you can also use orgmode in this way. This has a few additional limitations, but also gives you access to a whole ecosystem of tools built into the orgmode system.
The primary 'limitation' with orgmode, compared to polymode, is that the main document has to be in org format. This is similar to markdown, and easily exported to html, latex/pdf, odt etc. It also has a lot more features for task management, scheduling (and a lot more).
You don't need to use all those features. The one you'll be interested in will be code blocks. You won't be able to use arbitrary delimiters, (i.e., triple backticks), you'll have to use the slightly more verbose orgmode style:
#+begin_src LANG
function foo()
println("Hello World")
println("Don't fill me please!")
end
#+end_src
The advantage here is that you can include code blocks of most (all?) languages in the same document, so long as there's an Emacs mode for editing them. You get the same syntax highlighting support as in polymode
. You don't get the seamless editing, but it's almost as good. There's a shortcut key for creating a temporary buffer for editing your code in its 'normal' mode, and then returning to your org document.
Both approaches are rather involved for your simple question. But if you do a lot of mixed-language editing I think it's worthwhile to learn one or the other, or both.
If you mostly use the same two languages, and especially if you have collaborators who don't use Emacs but want to edit your documents, I would recommend polymode. That's what I use for RMarkdown (markdown with R code blocks).
Orgmode is much more powerful and flexible, but it requires that you adopt the org format, and it won't be as easy to share with non-Emacs users. I use this for files that only I will edit, especially when I'm mixing more than two languages into a document.