You can, but you would have to adjust the recipe. Mash more grain to get a more concentrated wort so you would top up to lower the gravity down to your target. Hops would probably need some adjustment as well.
Or you can do like I do. Do a partial mash so that you're basically doing a 3 gallon or so version of the AG recipe, then add some extract to make up for the top up to 5 gallons. I did a write up on how I do it using Beersmith around here somewhere.