yes you can...[IF 3G]
first u have to Jilbreak it by Redsn0w very simple, {Google Will Help You} {If u have 3.1.3 or 3.1.2 go there}
http://forum.gsmhosting.com/vbb/f456/how-jailbreak-your-iphone-3-1-2-3-1-3-using-spirit-990761/
BUT IF YOU HAVE 4.0.1 OR 4.0 USE REDSN0W.
then you have to Unlock by Ultrasn0w
http://forum.gsmhosting.com/vbb/f456/iphone-dev-team-released-ultrasn0w-0-93-unlock-4-0-3g-3gs-w-0-wifi-1029375/
Good Luck