I will be arriving into Barcelona late when the train ticket office will be closed. Can I buy an Hola Card from a machine?
Yes. After ordering a Hola card online, you can pick up your card at any Metro Station.
The Hola Barcelona web page contains this:
Get your travel card at any metro station
We will email you a voucher with a personalised code. This code can then be used to collect your travel card at any metro station. Only Hola Barcelona offers this service. Save yourself the cost of postage and avoid the queues.
Watch this video with instructions to buy and collect your transport travel card.
There is a Metro Station at Barcelona El Prat Airport.
The Airport webpage above says the Metro operates Monday-Friday from 5:00 a.m. until midnight, and Saturday-Sunday 24 hours/day. Because the airport website is a secondary source, I would check the Metro's website for current opening times at the time of your trip.