I wouldn't admit guilt, there's no way a police officer should have given you a ticket while you were on your way home with a NEW bulb ready for replacement.
Plead not guilty, get your court date and the judge will probably get a laugh and toss it out.
I'm all for going in and pleading to a lessor charge if you've actually done someone wrong, but no way I'd do that in this case. That's complete Bull. Make sure you bring your receipt with you that shows the time/date on it!! Easily showing you knew you had the issue and were in the process of fixing it.