Sure, you can change the license, but the old license still applies to the code as it was before you changed it. Assuming you're using a legit open source license the first time around, nothing changes regarding how you can make use of the old code; all they can do is make it harder to find (close the repo) or harder to make use of (squashing/flattening the commits to make it impossible to get the correct historical version), both of which are trivially bypassed by using a third party fork or source release.