I think it is technically against the rules because the rangers want to reserve the space in the bear boxes for people who are actually camping there. I suspect that if you labeled your cache with your estimated pick up date and did not leave it there too long, they would probably leave it alone as I’ve seen caches in the Kearsarge Lakes bear box before.
Another option would be to rent another bear can from Yosemite (last time I checked it was only $5 for as long as you want) and cache your food near the bear box in your own bear can. I would still label it with your ETA, but I’m sure the rangers would not remove it if you did it that way. Of course, that would leave you with a spare can that you would either have to carry or pick up later.
A final option would be to cache the food in the bear boxes at the Onion Valley trailhead, which I do not think would violate any rules. Again, you would have to label it with your ETA as I often see rangers pulling out undated and outdated food packages from bear boxes at trailheads.
Good luck, and have a great hike!
Kanga