You can do it, but it would take some work to mitigate some risk.
First thing would be to get a sulphur wick to sterilize the interior of the barrel and even then, there may be some things that survive that you might not want. Then you'll need to condition the barrel so that it doesn't leak, which is a fancy way to say fill it with water until you don't get any more leaking. This may take from a few days to a couple weeks. Smaller barrels obviously take less time. I'd change out the water every day or so until you stop getting puddles. After that I would probably star-san the interior. And think about how to eliminate as much dead-space and air in the barrel as possible (ie. topping off to the bung, nitrogen tank, inflating a balloon inside to take up volume, etc).
You'd probably want to use this with a high-alcohol or high-hop brew to provide a measure of protection against some of the weaker strains of microbial tomfoolery, but if there's brett or something robust in the wood, there's not much you'll be able to do. If you want some really effective and user firendly directions on how to get a barrel ready for use, check out a book called "Vines to Wines" by Jeff Cox. He spends a couple pages walking you through the process.
In the meantime - the down side is that you end up with odd tasting beer or vinegar-beer or something and the up side is that it could be pretty cool.
I'd probably give it a shot and see what happens. Once you get a reliable beer-aging barrel, you could probably re-use it for quite a while.