Digital signatures with one-way function, can messages be longer than the signature? Ethereum and Bitcoin both use 512 bit signatures, can the message that is being signed be longer than 512 bit?
Yes.

Signature length is generally unrelated to the length of the message and the length of the key.  Some signature schemes have very short signatures and long public keys, like CFS; some have short keys and very long signatures, like SPHINCS; some are more balanced in size, like Ed25519 or RSA-2048-FDH.  Only exotic signature schemes for very special purposes are limited to short messages—the vast majority are designed to handle messages of arbitrary length.

Pretty much every signature scheme is designed with a random function from messages to elements of some mathematical structure for the public-key cryptosystem.  This serves to destroy any relations in structured messages.  If we didn't do that, e.g. if we used RSA with the stupid verification equation $s^3 \equiv m \pmod n$ for a signature $s$ on a message $m$ under public key $n$, then you could trivially forge the signature $s = 1$ on the message $m = 1$ under any modulus $n$ because $1^3 \equiv 1 \pmod n$.  Instead, serious practitioners use a sensible verification equation like $s^3 \equiv H(m) \pmod n$ where $H$ is a random function from messages to $\mathbb Z/n\mathbb Z$ so you have no hope of finding an $m$ such that $H(m) = 1$.

Practical signature schemes are usually instantiated with a fixed hash function $H$ accepting arbitrary bit strings as inputs, like SHAKE256.  This is not simply ‘hashing a message, and then signing a hash’—the hash is an integral part of the signature scheme itself, not something you do in addition to signing; the security of the signature scheme relies critically on the hash.

In the signature scheme that Bitcoin uses with the OP_CHECKSIG operation, the message, a transaction, is an arbitrary bit string, mapped with SHA-256d (that is, two iterations of SHA-256, $m \mapsto \operatorname{SHA-256}(\operatorname{SHA-256}(m))$) into a scalar modulo the order of the curve secp256k1.