An S5 can be unlocked, yes. Whether it can work with AT&T will depend on the region it was made for and frequencies it utilizes (there are regional variants).
Usually you'd contact the carrier it's locked to for unlock, or go to a third party store etc (or online!). I doubt you could just call up AT&T and have it unlocked......unless AT&T are the ones who locked it down (and if they were, you could just use it outright, so I assume they're not.