I want to store data using custom classes. I found this forum entry: https://godotengine.org/qa/90341/custom-classes

The code it includes to create a custom class is this:

class My_Class:
    var a: int
    var b: String
    var c: float
    
    func _init(a, b, c):
        self.a = a
        self.b = b
        self.c = c

(I made some changes because the Godot editor was angry with me, I think Godot 4 changed some things)
This code seems to work, or at least it doesn't throw an error when running the game.

However, once I try to create an instance of it:

var a = My_Class.new(1, 'Test', 1.23)
print(a)

I get the error: Unexpected "Identifier" in class body

I am not quite sure what the problem is and when I look for classes in the docs I end up with lots of info on nodes and classes.

I suppose the important question is what is wrong with the code and the other question is whether something like this is the proper way to use Godot. Ultimately, I want to create a list of cities and store all of that in a dictionary, like so:

var cities = {
    'Town A': City(pos, population, production),
    'Town B': City(pos, population, production),
}

Every GDScript file is an implicit class definition. Classes defined inside such files using the class keyword represent so called inner classes. You can instantiate them like in your example from within the same script file. However their names are guarded by the outer class namespace. So from other scripts you must access them via that namespace:
script 1:

class_name Foo
extends Node

class My:
	pass	

func _ready():
	print(My.new()) # works here

script 2:

# we're in anonymous namespace without declaring the class_name
extends Node

func _ready():
	print(Foo.My.new()) # need to go via Foo namespace

If you want to define a top level class whose name is available project-wide you need to give it its own *.gd file and inherit (typically) from RefCounted:

class_name City
extends RefCounted

var population = 1
# etc