P.S. Ideally, I'd like to insert this code in google tag manager.
This is very possible and many Marketo users have done this. You'll need to work with your engineers to write the script that reads the cookies and populates the field values with the cookie value. They should be able to make it so that it works on *.abcxyz.com and is therefore both Marketo and corporate site friendly.
I wouldn't bother with a cookie here if it's all on the same origin. That's just more libraries to load (though I've written my own cookie library in the past, going with widely-used libraries is a better bet, but you end up with another script include).
What you're talking about is saving the source query param when you first see it (not overwriting it), then injecting it into each form. Like so: MktoForms2 :: Touch to Field
I'm not going to recommend GTM for anything. Where you load the script(s) from is up to you.