Pass hidden fields using drupalSettings to Twig template
Wish I could comment...

Are you sure your hook is running?  the instanceof operator is not implemented correctly so you should be seeing an error when the hook tries to run.  

Also, you may not need to add 'drupalSettings' to the 'elements' key.  You should be able to put it on the top level of $variables.