For me what worked is to add an attribute [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'foo')] (where foo is the variable to supress) to the script scope (i.e. at the very top of the file, before anything else) and add an empty param() to the top of the file for the attribute to bind to.
You can't assign attributes to variables, and PSScriptAnalyzer doesn't understand the concept of Pester's named script blocks, so it has to be done up top.
Before:
After:
Notice how $foo is now being suppressed as intended, but $bar doesn't get suppressed as there is no attribute for it.