Yes, they are etymologically connected. The word sham seems to derive from an English dialectical variant of shame. The meaning “pillow covering”, which came later, is related to the meaning of sham as something meant to look like something else, a false front, a facade.