Yes impersonating an officer is a crime and can land you in jail or even prison depending on the laws in your state and what you did when impersonating the officer.
If you just happen to be caught impersonating an officer then you may just get arrested and go to jail and be able to bail out.
Then you might just get a fine or a few months in jail.
Then again you might get a year in jail for impersonating the officer.
Now if you impersonate an officer and actually do arrest someone or harm someone while impersonating an officer than you would likely get a few years in prison to as much as 10 to 15 years or longer impersonating an officer.
Dressing up as a police officer for Halloween is okay as long as you do not try to make an arrest but any other time you can be arrested and get into trouble impersonating a police officer.