Trying to create dynamic widget area using post ID

In your code you are trying to register a different sidebar for every post. Now, that would be possible (though with slightly different code), but it would mean that if you have, say, a hundred posts, you would have hundred widget areas in your admin, all of which you would have to fill with different widgets that have their own content.

I don’t know what exactly you are trying to achieve, but if you want to pull information from specific posts in a sidebar, you probably want to build a widget. You can still have unique information on every page, but not a cluttered widget dashboard.

I can think of more complicated setups, but you would have to provide more detail on what you are trying to achieve.