input: Write a function to parse a json-formatted string into a dictionary in Python. If the input string cannot be parsed, raise a ValueError. The function should return the dictionary if parsing is successful.
  
  assert parse_json_to_dict('{"name": "John","age": 30,"address": {"city": "New York","state": "NY"}}') == {"name": "John","age": 30,"address": {"city": "New York","state": "NY"}}
  assert parse_json_to_dict('{"foo": "bar", "baz": 123}') == {"foo": "bar", "baz": 123}
  assert parse_json_to_dict('["hello", "world"]') == ValueError
output: def parse_json_to_dict(json_str):
      try:
          return json.loads(json_str)
      except json.JSONDecodeError:
          raise ValueError