A man who pleaded guilty to possessing a shotgun without a certificate has avoided jail.