Seven states have required gun registries. It is not illegal for a state to have a registry. It is illegal for the federal government to have a gun registry with exceptions for NFA controlled arms.
https://www.congress.gov/crs-product/IF12057