Javascript inside LD JSON
No, scripts of the type "application/ld+json" won't be executed. But, you could do something like this:
<script> var el = document.createElement('script'); el.type = 'application/ld+json'; el.text = JSON.stringify({ "@context": "http://schema.org", "@type": "WebSite", "url": "http://" + window.location.hostname }); document.querySelector('body').appendChild(el);</script>