Yes, you can be laid off from a small company because they lose one of their large clients for reasons that are absolutely nothing to do with you.
They will then look to trim off "luxury expenses" and if they are not a tech company, having a full time IT/dev guy is likely to be one of them.
At big companies, if it is done right, the upper level management may ask for input from 1st line managers as to who they should fire. Also, my last company, all managers had to rank their underlings, and those at the bottom had a chance of being trimmed if there were layoffs.
Many big companies will listen to those first line managers, and almost any upper-level manager is aware of their lack of knowledge about the leaves of the management tree.