Although it is possible to do this, it is a bad idea because the code is tied to that particular WordPress theme. So if you switch to a different theme or update the existing one, you risk losing that code.