Shopify actually uses cookie discount_code. All you need to do is deploy the following script via GTM on all pages. It will grab discount url param and store it to discount_code cookie. Shopify will pick it up automatically.
<script>
(function() {
var params = new URLSearchParams(window.location.search);
if (params.has('discount')) {
var discountCode = params.get('discount');
document.cookie = "discount_code=" + encodeURIComponent(discountCode) + "; path=/; max-age=" + (30*24*60*60);
}
})();
</script>