In you sandbox environment, you can have both 3,1 and 4.1 on the same server. but CMS DB will be different. It is not going to overwrite 3.1 install with 4.1. You will have 2 separate installs with separate CMS DB.
But in Production of , recommend to have 4.1 on completely new server and move the content using UMT.