In the case of you working for one employer the whole year, the systems in place are designed to make sure you can't exceed the limits defined in US tax law.
There are generally three ways to get money into a 401(k). Payroll deduction from your paycheck. Matching funds, profit sharing, or some other reason from corporate funds. The third way is by rolling money into the 401(k) plan. The law expects the company to make sure the source of the funds is from retirement funds and isn't just a check from regular bank account.
There is one potential apparent loophole. If you work for multiple employers during the year, they would have no idea how much money you put into the other plan. So it would seem that you could be at or below the maximum amount for each employer and then exceed the limits when the numbers are combined. This won't work because early the next year the 401(k)s will report your contribution and rollover numbers to the IRS.
At some point later the IRS will know you went over the limit, and you will be responsible for withdrawing excess funds, and will be responsible paying taxes, and potentially interest and penalties. Note that this reporting will also be a way for the IRS to know if you used regular funds to roll money into a 401K.