First, decompile apk file with [apktool](https://apktool.org):

```
apktool d &lt;file_name&gt;.apk
```

Replace assets or edit *Manifest.xml*. [smali2java](https://github.com/AlexeySoshin/smali2java) can be of use for code modifications.

Recompile apk:

```
apktool b &lt;file_name&gt;
```

Alignment is necessary for modern android versions (I believe, 30+ SDK):

```
zipalign -v -f -p 4 &lt;file_name&gt;/dist/&lt;file_name&gt;.apk aligned-&lt;file_name&gt;.apk
```

Create a signing key. Fields values do not matter. Especially for personal use.

```
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 1000
```

Actually sign apk with it:

```
apksigner.jar sign -ks my-release-key.keystore --ks-key-alias alias_name aligned-&lt;file_name&gt;.apk
```

It will overwrite the provided apk with a signed one.

We're awesome!
