When creating categories in a blend file's asset library blender creates a .txt file in the home directory where the categories are stored. Is there a way to not use this .txt file but save the categories internally in the .blend file?
It is not possible. The only thing that's stored in the .blend file is the catalog's UUID on each individual asset, which is used at runtime to link the asset to its catalog in the definition file and place the assets accordingly.
It is part of the design of the Asset Browser workflow to rely on an external file to define catalogs.
It may or may not change in the future though, since it's the first iteration of this feature.