Absolutely you can wear both hats at the same time, how effectively you can do so is largely a matter of time management.
Management is both a skill set and a job description. From that it encompasses various tasks that you perform. When I managed a team of 10, I was the "HR" manager as well as their technical team lead. I assigned work (yes, not agile...) dealt with small budgetary matters, general HR hire/fire/review/holiday/etc. stuff and the like.
Some of that work goes up with the number of people managed, and some is more fixed based on yes/no. The number of staff you have does not really impact how long you spend on your budget, but does impact how long it takes to perform their mid-year reviews and document them to HR satisfaction.
With a team of 10, I primarily oversaw, reviewed code, and was the person to bounce ideas off. With a team of only 5, however, there was much more time for actual coding.
To use a crude made-up formula as an analogy, my personal experience would be something like
Dev-Time-As-Percent = 100 - Fixed-Managerial-Overhead - (Staff-Count * 5)
Here I am presuming that each individual is 5% of my working time - averaged out. Some need more on some days, etc. The fixed part is the stuff I mentioned like budgets, which tends to be invariant - either I have to make one or I do not. The staff count is also an input to the numbers in the budget, but the staff count doesn't change the effort of creating the budget much.
What you do with that leftover time is up to you, and your boss! In my case, I mostly fixed bugs in order to keep my hands dirty in the code, and because my time did indeed vary, I was therefore not a bottleneck for larger features.
Any job, like bits on a hard disk, or furniture in a house, can expand to fill space (time) available. So it all goes back to time management. Do you get the management stuff done-done and can you then do other things? Or is the management stuff taking 100% of your time regardless of the size of team?