For encrypted files, yes:
https://github.com/daveTheOldCoder/Godot3To4FileConversion#example-5
For non-encrypted files, the data doesn't have a known structure that can be examined to reliably determine its type. The best you can do is to try reading the file and make a conclusion based on whether you get errors.
If you know how the file was created, for example, if you know that the file begins with a Dictionary written by Godot 3's File.store_var() or Godot 4's FileAccess.store_var(), you could distinguish between the two cases by reading the second four bytes, which contain the Variant.Type. For Godot 3 it would be 18, and for Godot 4 it would be 27.