Is it possible to change the DNS server and flush the DNS cache based on the user that is logged in via a Windows group policy or login script?
Yes and no.
Yes: you could change the DNS per user via a startup script that is launched via Group Policy.
No: DNS settings are machine local, so all users must share the settings. If you have two concurrent users there is no way for each user to have a different DNS setting if both users are connected at the same time.
So if you used a startup script, who ever logged in last would set the DNS for all of the connected users.