It can, but the most common issue with doing this is that only the really high-end L3 switches support NAT. So, unless you plan to run everything on the switch with public addressing, that limitation is likely going to be a problem.
The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
To add to what Jody has already posted, L3 switches often lack features commonly found on routers. Often such features are WAN related. Jody mentioned one common WAN feature, NAT, but they might also lack certain hardware resources, such as sufficient capacity to take one or more full Internet route tables.
Even when running across MetroE clouds, often LAN L3 switches are still a bit "weak", for such usage, which is why Cisco has a series of MetroE switches.
The forgoing doesn't mean you cannot use a LAN L3 switch, just you need to be careful matching what the switch can do with your WAN feature needs.