Robust simulation-based inference in cosmology with Bayesian neural networks