I think you would have enough time to walk around a little bit. For the Taxi ride to Valletta i would calculate 30 minutes one way (i suggest to preorder an eCab, they will be waiting at the airport for you). If you have checked luggage, i think you should be back at the airport 2 hours before your flight, however with only hand luggage or if your luggage is checked through, 90 minutes should be sufficient. I never encountered long lines at the security check.
For Valletta itself, as a destination for the cab i suggest the Triton fountain. That's also where the Bus terminal is. You can then walk over to the Upper Barrakka gardens, where you have a nice view over the bay.