You cannot use JailBreakMe method to jailbreak and unlock iOS 4.0.2 on iPhone 3G. However you can still jailbreak and unlock iPhone 3G using redsn0w. Here are the instructions:
Run RedSn0w and point it at the 4.0 IPSW. (Yes – point it at the 4.0 IPSW even though you’re at 4.0.2). This will also hacktivate your iPhone3G at 4.0.1 if you haven’t already been activated by iTunes.
If you need a carrier unlock – install ultrasn0w in Cydia (add repository http://repo666.ultrasn0w.com). For T-Mobile in the USA remember to turn off 3G mode in Settings→General→Network.
Run RedSn0w and point it at the 4.0 IPSW. (Yes – point it at the 4.0 IPSW even though you’re at 4.0.1). This will also hacktivate your iPhone3G at 4.0.1 if you haven’t already been activated by iTunes.
Install ultrasn0w in Cydia (add repository http://repo666.ultrasn0w.com) if you need a carrier unlock (and in the USA, remember to turn off 3G mode in Settings→General→Network).
DevTeam successfully jailbreaked new iOS 4. They updated jailbreak utility redsn0w to version 0.9.5b5-3. Supported devices are iPhone3G and iPod Touch 2G (not MC). New redsn0w is also able to hacktivate iOS 4.0 for iPhone3G.