Jordan Dufty, 18, was arrested shortly after accompanying friend Toby Pinder, 19, who was running away from home due to a dispute.
They were arrested after being approached by a police community support officer who then discovered both were carrying weapons.
Mr John Oates, prosecuting barrister, said: "It was realised that the defendant was wanted for arrest for another imitation fire arm offence.
"The officer asked him if he had anything that he should not and the defendant produced an imitation pistol of a BB firing gun that had been interfered with so that the blue part had been painted black to make it look real.
"If seen by a member of the public, or by firearms police officers it would appear to be a real gun.
"He also admitted that he had cannabis in his possession. When the other male was searched he had a similar weapon and a machete."
Shrewsbury Crown Court heard that the father-to-be was given a detention and training order for a similar offence, robbery and attempted robbery last year.
But he failed to comply with the order and was fined £50.
He also missed a subsequent court appearance.
Miss Lucinda Wilmott-Lascelles, mitigating barrister, said: "He explained to me this morning that he deeply regrets the way that he behaved. At the time he had just turned 18."
Dufty, of Worcester, was convicted of an offence possession of an imitation firearm, and possession of cannabis following a trial at Kidderminster Magistrates' Court.
For the firearm offence he was sentenced to six months' youth detention, and for the cannabis he was given a 12-month conditional discharge.
He admitted the bail offence and was given two weeks' detention to run consecutively to the airgun term.
At a previous hearing Pinder, of Balsall Heath, Birmingham, was sentenced to an 18-month community order, 160 hours of unpaid work and 30 rehabilitation activity days after admitting to two counts of carrying an offensive weapon in a public place.